nengo / nengo-loihi

Run Nengo models on Intel's Loihi chip
https://www.nengo.ai/nengo-loihi/
Other
35 stars 12 forks source link

Tutorial Bug. TypeError: make_step() missing 1 required positional argument: 'state' #237

Closed wssrc closed 5 years ago

wssrc commented 5 years ago

Describe the bug I'm trying out the tutorial on CNNs with Nengo_Loihi, and I get this error "TypeError: make_step() missing 1 required positional argument: 'state'" When i run this code

`do_training = False

with nengo_dl.Simulator(net, minibatch_size=minibatch_size, seed=0) as sim: if do_training: print("error before training: %.2f%%" % sim.loss(test_data, {out_p_filt: classification_error}))

    # run training
    sim.train(train_data, tf.train.RMSPropOptimizer(learning_rate=0.001),
              objective={out_p: crossentropy}, n_epochs=5)

    print("error after training: %.2f%%" %
          sim.loss(test_data, {out_p_filt: classification_error}))

    sim.save_params("./mnist_params")
else:
    download("mnist_params.data-00000-of-00001",
             "1BaNU7Er_Q3SJt4i4Eqbv1Ln_TkmmCXvy")
    download("mnist_params.index", "1w8GNylkamI-3yHfSe_L1-dBtvaQYjNlC")
    download("mnist_params.meta", "1JiaoxIqmRupT4reQ5BrstuILQeHNffrX")
    sim.load_params("./mnist_params")

# store trained parameters back into the network
sim.freeze_params(net)`

The Stack trace points to the line with nengo_dl.Simulator(net, minibatch_size=minibatch_size, seed=0) as sim: But it also indicates that it originated from nengo_dl\tensor_graph.py

To Reproduce I just followed the tutorial by copying and pasting. I have nengo version 3.0.0, nengo_loihi version 0.8.0, and nengo_dl version 2.1.1

drasmuss commented 5 years ago

This is due to a recent change in nengo core (3.0.0 is a development version, it isn't stable), which is not yet supported in nengo-dl. However, nengo-dl should be updated sometime this week (you can follow this PR for updates https://github.com/nengo/nengo-dl/pull/94).

Note that you will need to do a developer install of nengo-dl (the same way you installed nengo core 3.0.0) in order to get those updates once they are released. We'll also be doing a new stable nengo-dl release shortly after those changes are merged in though.

If you want to get your code working right away, you just need to downgrade your development version of nengo to a version that is supported by nengo-dl. E.g., from the nengo directory, do

git checkout 026b94398fc111f0a39c94385cf1c476b3b9af1b

and then everything should work.

wssrc commented 5 years ago

When I had Nengo version 2.8, it said that nengo.Convolution did not exist, which is why I did the developer upgrade. Is there a way I can experiment with the CNN capability of Nengo_Loihi while I'm waiting for nengo-dl to be updated?

drasmuss commented 5 years ago

Yes, following those last steps there (the git checkout 026b94398fc111f0a39c94385cf1c476b3b9af1b part) should allow you to use Convolutions with nengo/nengo-dl/nengo-loihi.

drasmuss commented 5 years ago

Note that if you want to do it with a simple one-liner through pip, rather than manually switching branches with git, you can do

pip install git+https://github.com/nengo/nengo.git@026b94398fc111f0a39c94385cf1c476b3b9af1b
wssrc commented 5 years ago

I still got the same error even after doing the new pip install you suggested, but I did the developer install with nengo-dl and import it with python, it complains that import nengo-dl is invalid syntax Which I fixed by changing nengo-dl to nengo_dl. After I closed the window and reopened it, everything worked fine