How can I run the model multiple times?

Hey there,
I am trying to create a network model and I added that model some randomness. So, in order to see what kind of changes have occured in the system each time I run, I tried to the model multiple times with for loop:

with nengo.Simulator(model) as sim:

    n_steps = 5
    for i in range(0, n_steps):

But It seems like whenever i run the system with “for i” the system picks up where it left off "0.5->1.0->1.5 ". But I want the model to start over every time to collect data from each simulation. I would be very grateful if someone could help me with that. Thanks!

hello! to regenerate the model each time and start from time zero, the easiest way is to put the for loop outside the with block.

data = []
for ii in range(0, n_trials):
    with nengo.Simulator(model) as sim:

Note that i’m assuming you have a probe in your network.

Alternatively, at the end of the for loop you can call sim.reset(), but note that the network won’t be regenerated so you’ll be running a network with all the same parameters.

1 Like

Thank you so much for your kind respond. When I put the for loop outside the with block, it solves my problem :+1:.