Running in standalone mode - Did I successfully avoid NotImplementedError or did I do something wrong?

Description of problem

Hello, I am a newbie to Python and spiking neural networks, and I’m facing a problem I’m not capable of solving.

I’m trying to run MNIST dataset classification code written with Brian2 in standalone mode. I’m going for cuda, but the same error is raised for c++ standalone mode.

The code written with Brian2 (which is called ‘original version’ in the code attached below) isn’t written by me and the copyright notice is presented within the code.

I modified this code in order to run with Brian2cuda library,
by importing brian2cuda and adding two lines at the beginning and at the end (There are multiple run() calls) :
“set_device(‘cuda_standalone’, build_on_run=False)”
“‘output’, compile=True, run=True, debug=False)”

Several NotImplementedError has occurred, so I modified the code and that error isn’t occurring anymore, but now the simulation is repeating in the same place, not progressing.

Minimal code to reproduce problem

The code is uploaded to my GitHub page.

What you have already tried

I made code to avoid NotImplementedError but I guess I’ve done something wrong?

Expected output (if relevant)

The variable ‘j’ in line 688 should increase, but it stays at value 1 for forever.

Actual output (if relevant)

The following lines are repeating infinitely.

create connections between X and A
create STDP for connection XeAe
create connections between X and A
create STDP for connection XeAe
run number: 1 of 20000

Hi Elina,

after a quick glance at your code, I would assume you are repeatedly ending up in line 718-722, which sounds like there are not enough spikes being produced. You could add a print statement there to see how/if the inputs are modified.

If you run your modified version (without NotImolementedError) in cpp_stabdalone, does it also get stuck there?

Hi, I’ve tried my code of the modified version in cpp_standalone, and it also gets stuck in the same part (variable ‘j’ stays at the value 0).
I checked lines 718-722 and I found out that the updated connection weights are not applied because they were not implemented before the simulation, and therefore I’ve made some corrections.
After that, the code ran fine and when I checked the input varying in lines around 718-722 and above them, I found that the input intensity, the weight matrix, and the input rate are updated while running through the loop but the spike count is always 0 so therefore ‘j’ is never updated. In other words, Even though the spike rate of pre-neurons increases the spike count of post-neurons remains 0.

Is this because the spike count gets the value from ‘SpikeMonitor’ from brian2 but since the simulation hasn’t started yet the spike is never generated? Should the be executed before counting the spikes?

If that’s the reason, how should I count the spikes and make the model learn MNIST classification?

Just in case, I made a link to the code for the cpp_standalone mode I’ve modified.

Thank you.

Hi @Elina. I know it has been a while since you posted this – do you still need help with this issue?