I’ve found this simple RL model that solves the Gym CartPole-v0. I want to try to convert it to a spiking network just for a try.
I’m struggling to find a conversion for the GradientTape (they use GradientTape instead of fit). And even for the predict function… (error: input_1 data: should have rank 3 (batch_size, n_steps, dimensions), found rank 2)
Can you provide a link or a snippet of the code you are using? Without that context, it’s hard to advise on how to achieve your goals.
In regards to converting an ANN to a spiking neural network, the NengoDL package can be used to convert TensorFlow / Keras models into spiking neural networks. We provide an example on how to do it here.
I already read about NengoDL and saw that example. But for a guy like me, that has zero experience in Nengo DL, the gap from the well explained example to real life problem is huge
I am a quite busy with other work at the moment. I will get back to you when I am more available. Hopefully soon.
Just briefly, from my quick read of it, the GradientTape is a method which you use to train a network. This is distinct from the network definition itself.
NengoDL itself doesn’t natively support GradientTape, as NengoDL uses a different method for training and simulating ANNs and SNNs. With NengoDL, you’ll be able to convert the ANN network (just the network) to a spiking one, but you’ll want to figure out exactly what you want to achieve with the ANN before I can really advise further. As an example, here are some questions that you’ll need to address:
What do you want the network to learn / be trained?
Thank you. As you can see it solves the Gym CartPole-v0 environment, so all the questions have an answer. My problem is converting the GradientTape and the predict. If you can assist when you available, I will really appreciate that.
This error means that your input data needs to have 3 dimensions (i.e., my_input.shape should be (x, y, z)). But your input data has 2 dimensions (x, y). This is probably because your data doesn’t have a temporal dimension (the n_steps in the error message), which you would need to add (e.g. if you want to run your model for 10 steps, then you need 10 steps of input).