Skip to content

Commit 420c5c8

Browse files
author
rbodo
committed
Fixed corner case where the reported average spike rate would be zero.
1 parent fd843ec commit 420c5c8

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

snntoolbox/simulation/target_simulators/INI_temporal_mean_rate_target_sim.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def __init__(self, config, queue=None):
4141
self._spiking_layers = {}
4242
self._input_images = None
4343
self._binary_activation = None
44-
self.avg_rate = None
4544
self._input_spikecount = None
4645

4746
@property
@@ -142,9 +141,7 @@ def simulate(self, **kwargs):
142141
print("Current accuracy of batch:")
143142

144143
# Loop through simulation time.
145-
self.avg_rate = 0
146144
self._input_spikecount = 0
147-
actual_num_timesteps = self._num_timesteps
148145
for sim_step_int in range(self._num_timesteps):
149146
sim_step = (sim_step_int + 1) * self._dt
150147
self.set_time(sim_step)
@@ -157,7 +154,6 @@ def simulate(self, **kwargs):
157154

158155
if self.config.getboolean('simulation', 'early_stopping') and \
159156
np.count_nonzero(input_b_l) == 0:
160-
actual_num_timesteps = sim_step
161157
print("\nInput empty: Finishing simulation {} steps early."
162158
"".format(self._num_timesteps - sim_step_int))
163159
break
@@ -180,7 +176,6 @@ def simulate(self, **kwargs):
180176
if hasattr(layer, 'spiketrain') \
181177
and layer.spiketrain is not None:
182178
spiketrains_b_l = keras.backend.get_value(layer.spiketrain)
183-
self.avg_rate += np.count_nonzero(spiketrains_b_l)
184179
if self.spiketrains_n_b_l_t is not None:
185180
self.spiketrains_n_b_l_t[i][0][
186181
Ellipsis, sim_step_int] = spiketrains_b_l
@@ -236,13 +231,6 @@ def simulate(self, **kwargs):
236231
"but {} input events were not processed. Consider "
237232
"increasing the simulation time.".format(remaining_events))
238233

239-
self.avg_rate /= self.batch_size * np.sum(self.num_neurons) * \
240-
actual_num_timesteps
241-
242-
if self.spiketrains_n_b_l_t is None:
243-
print("Average spike rate: {} spikes per simulation time step."
244-
"".format(self.avg_rate))
245-
246234
return np.cumsum(output_b_l_t, 2)
247235

248236
def reset(self, sample_idx):

0 commit comments

Comments
 (0)