Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there anything like nest.ResetNetwork? #3

Closed
HilbertHuangHitomi opened this issue May 24, 2021 · 4 comments
Closed

Is there anything like nest.ResetNetwork? #3

HilbertHuangHitomi opened this issue May 24, 2021 · 4 comments

Comments

@HilbertHuangHitomi
Copy link

HilbertHuangHitomi commented May 24, 2021

I would like to run the simulation under different conditions automatically with a loop. It looks like this :

for i in range(times):
net = Network(sim_dict, net_dict, stim_dict)
net.create()
net.connect()
net.simulate(sim_dict['t_sim'])
SaveData()

However, when a simulation is completed, the next one would be stuck at net.create() , as ValueError: Nodes cannot be created after calibration.
I think we need a reset operation like nest.ResetNetwork to initialize the network before we start to create it again, but I could not find it. Is there anything like this, please?

@golosio
Copy link
Owner

golosio commented May 24, 2021

Unfortunately currently there is no reset function in NeuronGPU. As a possible workaround, if you are working in bash you can run an external bash script that launches the python script several times. If you need the loop step index, you can use a template python script and a substitution, as in the following example:
file prova.sh:

 #!/bin/bash
for i in $(seq 1 10); do
    cat prova_templ.py | sed "s/__i__/$i/" > prova.py
    python prova.py
done

file prova_templ.py:

run_index = __i__
print("Running step n. ", run_index)

To execute it, type:
. prova.sh
Let me know if this kind of solution is suitable for your needs.

@HilbertHuangHitomi
Copy link
Author

HilbertHuangHitomi commented May 25, 2021

Thank you for the response!
It works, but harder to maintain since it needs interactions between bash and python.
I found another solution, using the subprocess package. For example, in file main.py

for i in range(times):
subprocess.run(['python run_simulation.py'])

Then we can run the whole process by python main.py. It may be easier to use.

BTW, is NeuronGPU still actively developed? It is friendly to use for those who are familiar with nest and python. I think this is one important advantage above GeNN. I do look forward to more improvement :P

@golosio
Copy link
Owner

golosio commented May 25, 2021

Thank you for the interesting and useful solution!
Sure, it is actively developed. If you publish something using it, please cite:
https://www.frontiersin.org/articles/10.3389/fncom.2021.627620/full
Best, Bruno

@HilbertHuangHitomi
Copy link
Author

Thank you very much !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants