Giter VIP home page Giter VIP logo

Running the model in example/lenet/keras/, File "/home/zhulingling/.local/lib/python2.7/site-packages/brian/reset.py", line 153, in __call__ V[P.LS.lastspikes()] = self.resetvalue ValueError: shape mismatch: value array of shape (3456,) could not be broadcast to indexing result of shape (0,) about snn_toolbox HOT 10 CLOSED

neuromorphicprocessorproject avatar neuromorphicprocessorproject commented on May 16, 2024
Running the model in example/lenet/keras/, File "/home/zhulingling/.local/lib/python2.7/site-packages/brian/reset.py", line 153, in __call__ V[P.LS.lastspikes()] = self.resetvalue ValueError: shape mismatch: value array of shape (3456,) could not be broadcast to indexing result of shape (0,)

from snn_toolbox.

Comments (10)

rbodo avatar rbodo commented on May 16, 2024

Hi hellolingling,

It seems like the simulation is not producing any spikes. Please try increasing the simulation duration, e.g.

[simulation]
simulator = brian
duration = 100

I'm sure you will have noticed that Brian takes a long time to build the network. Nest is much faster, you might want to give it a try.

Best,

Bodo

from snn_toolbox.

hellolingling avatar hellolingling commented on May 16, 2024

Hi rbodo,

Thank you for your help! I changed my config file shown as below, but it has the same problem as before. Do you have some other ideas about the problem? Thank you!

[paths]
dataset_path = %(path_wd)s/../../../datasets/mnist
filename_ann = 98.96

[tools]
evaluate_ann = True

[simulation]
simulator = brian
duration = 100
num_to_test = 10
batch_size = 1
keras_backend = tensorflow

[input]
poisson_input = False

[output]
log_vars = {'all'}
plot_vars = {'all'}

from snn_toolbox.

hellolingling avatar hellolingling commented on May 16, 2024

@rbodo

ps. I agree with you that not spikes are generated. As the debug code show in the log:

The error information is shown as below:
Starting new simulation...

Current accuracy of batch:
(array([], dtype=int64), <type 'numpy.ndarray'>)
[]
<type 'numpy.ndarray'>
(array([0., 0., 0., ..., 0., 0., 0.]), <type 'numpy.ndarray'>)
((3456,), 3456)
[0. 0. 0. ... 0. 0. 0.]
Traceback (most recent call last):
File "", line 1, in
File "test.py", line 17, in sim

This piece of output is printed by my debug code:
def __call__(self, P): ''' Clamps membrane potential at reset value. ''' V = self.statevectors.get(id(P), None) if V is None: V = P.state_(self.state) self.statevectors[id(P)] = V print(P.LS.lastspikes(), type(P.LS.lastspikes())) print(V[P.LS.lastspikes()]) print(type(V[P.LS.lastspikes()])) print(V, type(V)) print(V.shape, V.size) print(self.resetvalue) V[P.LS.lastspikes()] = self.resetvalue in brian/reset.py Reset class.

from snn_toolbox.

rbodo avatar rbodo commented on May 16, 2024

Just to be sure, can you increase the simulation duration to 300?

Also, please let me know what version of Brian & pyNN you are using. I tried to reproduce your error, but with the latest versions of Brian (1.4.4.) and pyNN (0.9.2) I run into a different error:

Starting new simulation...

Current accuracy of batch:
Traceback (most recent call last):
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/bin/snntoolbox", line 9, in <module>
    load_entry_point('snntoolbox', 'console_scripts', 'snntoolbox')()
  File "/mnt/2646BAF446BAC3B9/Repositories/NPP/snn_toolbox/snntoolbox/bin/run.py", line 50, in main
    test_full(config)
  File "/mnt/2646BAF446BAC3B9/Repositories/NPP/snn_toolbox/snntoolbox/bin/utils.py", line 129, in test_full
    results = run(spiking_model, **testset)
  File "/mnt/2646BAF446BAC3B9/Repositories/NPP/snn_toolbox/snntoolbox/bin/utils.py", line 202, in wrapper
    results.append(run_single(snn, **testset))
  File "/mnt/2646BAF446BAC3B9/Repositories/NPP/snn_toolbox/snntoolbox/bin/utils.py", line 126, in run
    return snn.run(**test_set)
  File "/mnt/2646BAF446BAC3B9/Repositories/NPP/snn_toolbox/snntoolbox/simulation/utils.py", line 610, in run
    output_b_l_t = self.simulate(**data_batch_kwargs)
  File "/mnt/2646BAF446BAC3B9/Repositories/NPP/snn_toolbox/snntoolbox/simulation/target_simulators/pyNN_target_sim.py", line 138, in simulate
    self.sim.run(self._duration - self._dt)
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/lib/python2.7/site-packages/pyNN/common/control.py", line 111, in run
    return run_until(simulator.state.t + simtime, callbacks)
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/lib/python2.7/site-packages/pyNN/common/control.py", line 93, in run_until
    simulator.state.run_until(time_point)
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/lib/python2.7/site-packages/pyNN/brian/simulator.py", line 57, in run_until
    self.run(tstop - self.t)
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/lib/python2.7/site-packages/pyNN/brian/simulator.py", line 54, in run
    self.network.run(simtime * ms)
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/lib/python2.7/site-packages/brian/network.py", line 574, in run
    self.update()
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/lib/python2.7/site-packages/brian/network.py", line 518, in update
    f()
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/lib/python2.7/site-packages/brian/connections/connection.py", line 296, in do_propagate
    self.propagate(self.source.get_spikes(self.delay))
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/lib/python2.7/site-packages/brian/connections/otherconnections.py", line 67, in propagate
    C.propagate(spikes)
  File "/mnt/2646BAF446BAC3B9/VirtualEnvironments/anaconda3/envs/python2/lib/python2.7/site-packages/brian/monitor.py", line 165, in propagate
    if self.record.any():
AttributeError: 'collections.defaultdict' object has no attribute 'any'

As fas as I can tell, this new error lies on the side of the pyNN integration of Brian. Since Brian is not being actively developed anymore (superseded by Brian2), I would recommend moving to Nest as a pyNN backend. It is much faster and worked fine last time I checked.

from snn_toolbox.

rbodo avatar rbodo commented on May 16, 2024

By the way, I just found a bug when using tensorflow backend together with pyNN simulators. Please pull latest version for the fix. (This will help run Nest correctly, but will not fix the Brian issue above.)

from snn_toolbox.

hellolingling avatar hellolingling commented on May 16, 2024

Hi @rbodo ,

The installation information is Brian (1.4.4.) and pyNN (0.9.2). I changed the simulation duration to 300 as you suggested, but it comes out the same problem as before.

I also tried nest simulation, it works much faster. It comes out the problem shown as below:
`Starting new simulation...

Current accuracy of batch:
hello simrun
Traceback (most recent call last):
File "/home/zhulingling/.local/bin/snntoolbox", line 11, in
sys.exit(main())
File "/home/zhulingling/.local/lib/python2.7/site-packages/snntoolbox/bin/run.py", line 50, in main
test_full(config)
File "/home/zhulingling/.local/lib/python2.7/site-packages/snntoolbox/bin/utils.py", line 129, in test_full
results = run(spiking_model, **testset)
File "/home/zhulingling/.local/lib/python2.7/site-packages/snntoolbox/bin/utils.py", line 202, in wrapper
results.append(run_single(snn, **testset))
File "/home/zhulingling/.local/lib/python2.7/site-packages/snntoolbox/bin/utils.py", line 126, in run
return snn.run(**test_set)
File "/home/zhulingling/.local/lib/python2.7/site-packages/snntoolbox/simulation/utils.py", line 611, in run
output_b_l_t = self.simulate(**data_batch_kwargs)
File "/home/zhulingling/.local/lib/python2.7/site-packages/snntoolbox/simulation/target_simulators/pyNN_target_sim.py", line 140, in simulate
output_b_l_t = self.get_recorded_vars(self.layers)
File "/home/zhulingling/.local/lib/python2.7/site-packages/snntoolbox/simulation/utils.py", line 934, in get_recorded_vars
self.set_mem_stats(mem)
File "/home/zhulingling/.local/lib/python2.7/site-packages/snntoolbox/simulation/utils.py", line 969, in set_mem_stats
self.config.get('paths', 'log_dir_of_current_run'))
File "/home/zhulingling/.local/lib/python2.7/site-packages/snntoolbox/simulation/plotting.py", line 907, in plot_potential
plt.savefig(os.path.join(path, layer[1], filename), bbox_inches='tight')
File "/home/zhulingling/.local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 710, in savefig
res = fig.savefig(*args, **kwargs)
File "/home/zhulingling/.local/lib/python2.7/site-packages/matplotlib/figure.py", line 2035, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/home/zhulingling/.local/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2263, in print_figure
**kwargs)
File "/home/zhulingling/.local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 526, in print_png
with cbook.open_file_cm(filename_or_obj, "wb") as fh:
File "/usr/lib/python2.7/contextlib.py", line 17, in enter
return self.gen.next()
File "/home/zhulingling/.local/lib/python2.7/site-packages/matplotlib/cbook/init.py", line 624, in open_file_cm
fh, opened = to_filehandle(path_or_file, mode, True, encoding)
File "/home/zhulingling/.local/lib/python2.7/site-packages/matplotlib/cbook/init.py", line 609, in to_filehandle
fh = io.open(fname, flag, encoding=encoding)
IOError: [Errno 2] No such file or directory: '/home/zhulingling/workspace/snntoolbox/snn_toolbox/examples/models/lenet5/keras/log/gui/test/00Conv2D_6x24x24/Potential.png'
`
It seems like that the input file 'Potential.png' is not existed in my folder when I running the keras/lenet model. Can you give me some idea about the 'Potential.png'?
image

from snn_toolbox.

rbodo avatar rbodo commented on May 16, 2024

Sorry about that. Just uploaded a bugfix for it.

from snn_toolbox.

hellolingling avatar hellolingling commented on May 16, 2024

Hi, @rbodo
Do you mean you will upload a bugfix for the problem shown as below?
File "/home/zhulingling/.local/lib/python2.7/site-packages/matplotlib/cbook/init.py", line 609, in to_filehandle fh = io.open(fname, flag, encoding=encoding) IOError: [Errno 2] No such file or directory: '/home/zhulingling/workspace/snntoolbox/snn_toolbox/examples/models/lenet5/keras/log/gui/test/00Conv2D_6x24x24/Potential.png'

Thank you!

from snn_toolbox.

rbodo avatar rbodo commented on May 16, 2024

Yes, this bug should be gone now.

from snn_toolbox.

hellolingling avatar hellolingling commented on May 16, 2024

Hi, rbodo
I found that I haven't add log_dir_of_current_run = in config file. And this is why it cannot find Potential.png file. I tried to add several folders named '00Conv2D_6x24x24', '01MaxPooling2D_6x12x12' and so on, which can solve the problem.
Thank you for your kind help!

from snn_toolbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.