# Atom can't evaluate a line which the regular REPL can

**URL:** https://discourse.julialang.org/t/atom-cant-evaluate-a-line-which-the-regular-repl-can/17549
**Category:** New to Julia
**Tags:** juno, knet
**Created:** [November 15, 2018, 6:39am UTC](https://discourse.julialang.org/t/atom-cant-evaluate-a-line-which-the-regular-repl-can/17549 "2018-11-15T06:39:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ahmetumutdurmus](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@ahmetumutdurmus](https://discourse.julialang.org/u/ahmetumutdurmus)
#### Post date: [November 15, 2018, 6:39am UTC](https://discourse.julialang.org/t/atom-cant-evaluate-a-line-which-the-regular-repl-can/17549/1 "2018-11-15T06:39:40Z")

</div>

Hello,

I encountered this error when using a registered Julia package called “Knet” yet I wasn’t sure whether to post it as an issue for Knet or ask it here. I eventually decided to ask about it here as the error was only reproducible in Atom but the code ran smoothly in the regular Julia REPL.

So here is the problem:

I am using a deep learning package called Knet. When I run the following code at the REPL I get the desired results and expected outputs:

```julia
julia> using Knet

julia> x = Param([1,2,3])
3-element Param{Array{Int64,1}}:
 1
 2
 3

julia> y = @diff sum(abs2,x)
T(14)

julia> println(grad(y, x))
[2, 4, 6]

```

`Param`, `@diff` and `grad` are Knet functions. The documentation regarding them are as follows:

```julia
   Param(x) returns a struct that acts like x but marks it as a parameter you want to compute
   gradients with respect to.
 
   @diff expr evaluates an expression and returns a struct that contains its value (which should be
   a scalar) and gradient information.
 
   grad(y, x) returns the gradient of y (output by @diff) with respect to any parameter x::Param,
   or nothing if the gradient is 0.

```

Yet when I try to run the same code line by line using Shift+Enter in Atom first two line run with no problem and the third line (namely `y = @diff sum(abs2,x)`) produces the following error:

```julia
Julia Client – Internal Error
MethodError: no method matching iterate(::AutoGrad.Node)
Closest candidates are:
  iterate(!Matched::Core.SimpleVector) at essentials.jl:578
  iterate(!Matched::Core.SimpleVector, !Matched::Any) at essentials.jl:578
  iterate(!Matched::ExponentialBackOff) at error.jl:171

```

What seems to be the problem here?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [November 15, 2018, 8:56am UTC](https://discourse.julialang.org/t/atom-cant-evaluate-a-line-which-the-regular-repl-can/17549/2 "2018-11-15T08:56:39Z")

</div>

I would argue that this is a “bug” in AutoGrad.jl, because they introduce a typealias for `Tape = IdDict{Value,Node}` and [overload `iterate` for that](https://github.com/denizyuret/AutoGrad.jl/blob/94eca8d0d8c956b766545458c83beaaf1d552741/src/core.jl#L28) to return something different from a normal `AbstractDict`. Usually one would expect to get a `key => value` pair back, but `iterate(::Tape, ...)` only returns the value.

On the Juno side, the issue only appears since  
[https://github.com/JunoLab/Atom.jl/pull/134](https://github.com/JunoLab/Atom.jl/pull/134)  
was merged, because before that PR we would’ve just used the (working) `show` method for the `Tape`.

---

<div class="post-metadata">

### Author: ![denizyuret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/denizyuret/32/568_2.png) [@denizyuret](https://discourse.julialang.org/u/denizyuret)
#### Post date: [December 25, 2018, 10:23am UTC](https://discourse.julialang.org/t/atom-cant-evaluate-a-line-which-the-regular-repl-can/17549/3 "2018-12-25T10:23:52Z")

</div>

Can you check with AutoGrad commit 09d4dfd ? I redefined Tape for the next release and wanted to find out if it fixes your issue.
