I plan to use nengo_bio to create a cerebellum model, using PES online learning rules. So, how do you save the trained weights (decoder and encoder) and reproduce it?
By the way, how to input a pulse of a specified frequency into the entire network?
Any ideas or suggestions are welcome！
Thank you for your questions! You may want to consider to open several threads if you have multiple questions in the future. This may make the questions and their answers easier to find.
Regarding your first question, NengoBio does not use encoders/decoders. Thus, if you have a
bio.Connection object, you can only access the corresponding full weight matrices. You can access the computed weights as follows (there should also be an example doing this in the NengoBio example notebook):
with nengo.Network(seed=5892) as net: ens_a = bio.Ensemble(n_neurons=101, dimensions=1, p_exc=0.5) ens_b = bio.Ensemble(n_neurons=102, dimensions=1, p_exc=0.5) conn = bio.Connection(ens_a, ens_b) with nengo.Simulator(net) as sim: wE = sim.data[conn].weights[bio.Excitatory] wI = sim.data[conn].weights[bio.Inhibitory]
You can restore these weights by simply overriding them at any time during the simulation.
Edit: You might want to use the
[...] syntax to override the weights in-place, i.e., write
sim.data[conn].weights[bio.Excitatory][...] = wE
Regarding your second question, it is a little unclear what you mean by “pulse of a specified frequency”. Per definition, a pulse will be composed of an infinite number of frequencies with non-zero power. If you just want to generate a rectangle signal with a specified
t_off time you can use the following code:
def RectangleSignal(t_on, t_off): return lambda t: 1.0 if ((t % (t_on + t_off)) < t_on) else 0.0 with nengo.Network() as net: nd_input = nengo.Node(RectangleSignal(1.0, 1.0))
Thank you very much for your answer. By the way, if I use nengo.Connection and PES connection rules, how can I save and reproduce the connection weight at a certain point?
You can probe the
weights of a connection. See for example this tutorial: