def init_neurons(self, input_shape): """Init layer neurons.""" from snntoolbox.bin.utils import get_log_keys, get_plot_keys output_shape = self.compute_output_shape(input_shape) self.v_thresh = k.variable(self._v_thresh, name='v_thresh') self.mem = k.variable(self.init_membrane_potential(output_shape), name='v_mem') self.time = k.variable(self.dt, name='dt') # To save memory and computations, allocate only where needed: if self.tau_refrac > 0: self.refrac_until = k.zeros(output_shape, name='refrac_until') if any({ 'spiketrains', 'spikerates', 'correlation', 'spikecounts', 'hist_spikerates_activations', 'operations', 'synaptic_operations_b_t', 'neuron_operations_b_t', 'spiketrains_n_b_l_t' } & (get_plot_keys(self.config) | get_log_keys(self.config))): self.spiketrain = k.zeros(output_shape, name='spiketrains') if self.online_normalization: self.spikecounts = k.zeros(output_shape, name='spikecounts') self.max_spikerate = k.variable(0, name='max_spikerate') if self.payloads: self.payloads = k.zeros(output_shape, name='payloads') self.payloads_sum = k.zeros(output_shape, name='payloads_sum') if clamp_var: self.spikerate = k.zeros(input_shape, name='spikerates') self.var = k.zeros(input_shape, name='var') if hasattr(self, 'clamp_idx'): self.clamp_idx = self.get_clamp_idx()
def init_neurons(self, input_shape): """Init layer neurons.""" from snntoolbox.bin.utils import get_log_keys, get_plot_keys output_shape = self.compute_output_shape(input_shape) if self.v_thresh is None: self.v_thresh = tf.Variable(self._v_thresh, name='v_thresh', trainable=False) if self.mem is None: self.mem = tf.Variable(self.init_membrane_potential(output_shape), name='v_mem', trainable=False) if self.time is None: self.time = tf.Variable(self.dt, name='dt', trainable=False) # To save memory and computations, allocate only where needed: if self.tau_refrac > 0 and self.refrac_until is None: self.refrac_until = tf.Variable( tf.zeros(output_shape), name='refrac_until', trainable=False) if any({'spiketrains', 'spikerates', 'correlation', 'spikecounts', 'hist_spikerates_activations', 'operations', 'synaptic_operations_b_t', 'neuron_operations_b_t', 'spiketrains_n_b_l_t'} & (get_plot_keys(self.config) | get_log_keys(self.config))) and self.spiketrain is None: self.spiketrain = tf.Variable(tf.zeros(output_shape), name='spiketrains', trainable=False) if self.last_spiketimes is None: self.last_spiketimes = tf.Variable(-tf.ones(output_shape), name='last_spiketimes', trainable=False)
def init_neurons(self, input_shape): """Init layer neurons.""" from snntoolbox.bin.utils import get_log_keys, get_plot_keys output_shape = self.compute_output_shape(input_shape) if self.v_thresh is None: # Need this check because of @tf.function. self.v_thresh = tf.Variable(self._v_thresh, name='v_thresh', trainable=False) if self.mem is None: self.mem = tf.Variable(self.init_membrane_potential(output_shape), name='v_mem', trainable=False) if self.time is None: self.time = tf.Variable(self.dt, name='dt', trainable=False) # To save memory and computations, allocate only where needed: if self.tau_refrac > 0 and self.refrac_until is None: self.refrac_until = tf.Variable(tf.zeros(output_shape), name='refrac_until', trainable=False) if any({ 'spiketrains', 'spikerates', 'correlation', 'spikecounts', 'hist_spikerates_activations', 'operations', 'synaptic_operations_b_t', 'neuron_operations_b_t', 'spiketrains_n_b_l_t' } & (get_plot_keys(self.config) | get_log_keys(self.config))) and self.spiketrain is None: self.spiketrain = tf.Variable(tf.zeros(output_shape), trainable=False, name='spiketrains') if self.online_normalization and self.spikecounts is None: self.spikecounts = tf.Variable(tf.zeros(output_shape), trainable=False, name='spikecounts') self.max_spikerate = tf.Variable(tf.zeros([1]), trainable=False, name='max_spikerate') if self.config.getboolean('cell', 'payloads') \ and self.payloads is None: self.payloads = tf.Variable(tf.zeros(output_shape), trainable=False, name='payloads') self.payloads_sum = tf.Variable(tf.zeros(output_shape), trainable=False, name='payloads_sum') if clamp_var and self.spikerate is None: self.spikerate = tf.Variable(tf.zeros(input_shape), trainable=False, name='spikerates') self.var = tf.Variable(tf.zeros(input_shape), trainable=False, name='var') if hasattr(self, 'clamp_idx'): self.clamp_idx = self.get_clamp_idx()
def init_neurons(self, input_shape): """Init layer neurons.""" from snntoolbox.bin.utils import get_log_keys, get_plot_keys output_shape = self.compute_output_shape(input_shape) self.mem = k.variable(self.init_membrane_potential(output_shape)) self.time = k.variable(self.dt) if any({ 'spiketrains', 'spikerates', 'correlation', 'spikecounts', 'hist_spikerates_activations', 'operations', 'synaptic_operations_b_t', 'neuron_operations_b_t', 'spiketrains_n_b_l_t' } & (get_plot_keys(self.config) | get_log_keys(self.config))): self.spiketrain = k.zeros(output_shape) self.last_spiketimes = k.variable(-np.ones(output_shape))
def init_neurons(self, input_shape): """Init layer neurons.""" from snntoolbox.bin.utils import get_log_keys, get_plot_keys output_shape = self.compute_output_shape(input_shape) self.v_thresh = k.variable(self._v_thresh) self.mem = k.variable(self.init_membrane_potential(output_shape)) self.time = k.variable(self.dt) # To save memory and computations, allocate only where needed: if self.tau_refrac > 0: self.refrac_until = k.zeros(output_shape) if any({'spiketrains', 'spikerates', 'correlation', 'spikecounts', 'hist_spikerates_activations', 'operations', 'synaptic_operations_b_t', 'neuron_operations_b_t', 'spiketrains_n_b_l_t'} & (get_plot_keys(self.config) | get_log_keys(self.config))): self.spiketrain = k.zeros(output_shape) self.last_spiketimes = k.variable(-np.ones(output_shape))