Closed hellolingling closed 6 years ago
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
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'}
@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.
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.
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.)
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
Sorry about that. Just uploaded a bugfix for it.
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!
Yes, this bug should be gone now.
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!
When I run lenet keras model in snntoolbox, it caused error in simulation. The config file is shown as below: [paths] dataset_path = %(path_wd)s/../../../datasets/mnist filename_ann = 98.96
[tools] evaluate_ann = True
[simulation] simulator = brian duration = 30 num_to_test = 10 batch_size = 1 keras_backend = tensorflow
[input] poisson_input = False
[output] log_vars = {'all'} plot_vars = {'all'}
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
result = spiking_model.run(testset)
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 138, in simulate
self.sim.run(self._duration - self._dt)
File "/home/zhulingling/.local/lib/python2.7/site-packages/pyNN/common/control.py", line 111, in run
return run_until(simulator.state.t + simtime, callbacks)
File "/home/zhulingling/.local/lib/python2.7/site-packages/pyNN/common/control.py", line 93, in run_until
simulator.state.run_until(time_point)
File "/home/zhulingling/.local/lib/python2.7/site-packages/pyNN/brian/simulator.py", line 57, in run_until
self.run(tstop - self.t)
File "/home/zhulingling/.local/lib/python2.7/site-packages/pyNN/brian/simulator.py", line 54, in run
self.network.run(simtime * ms)
File "/home/zhulingling/.local/lib/python2.7/site-packages/brian/network.py", line 574, in run
self.update()
File "/home/zhulingling/.local/lib/python2.7/site-packages/brian/network.py", line 518, in update
f()
File "/home/zhulingling/.local/lib/python2.7/site-packages/brian/neurongroup.py", line 549, in reset
self._resetfun(self)
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,)
waiting for your help! Thank you!