ngclearn.components.input_encoders package

Submodules

ngclearn.components.input_encoders.bernoulliCell module

class ngclearn.components.input_encoders.bernoulliCell.BernoulliCell(*args: Any, **kwargs: Any)[source]

Bases: Component

A Bernoulli cell that produces Bernoulli-distributed spikes on-the-fly.

Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • key – PRNG key to control determinism of any underlying synapses associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
property inputCompartment
classmethod inputCompartmentName()[source]
property outputCompartment
classmethod outputCompartmentName()[source]
reset(**kwargs)[source]
save(**kwargs)[source]
property timeOfLastSpike
classmethod timeOfLastSpikeCompartmentName()[source]
verify_connections()[source]
ngclearn.components.input_encoders.bernoulliCell.sample_bernoulli(dkey, data)

Samples a Bernoulli spike train on-the-fly

Parameters:
  • dkey – JAX key to drive stochasticity/noise

  • data – sensory data (vector/matrix)

Returns:

binary spikes

ngclearn.components.input_encoders.bernoulliCell.update_times(t, s, tols)

Updates time-of-last-spike (tols) variable.

Parameters:
  • t – current time (a scalar/int value)

  • s – binary spike vector

  • tols – current time-of-last-spike variable

Returns:

updated tols variable

ngclearn.components.input_encoders.latencyCell module

class ngclearn.components.input_encoders.latencyCell.LatencyCell(*args: Any, **kwargs: Any)[source]

Bases: Component

A (nonlinear) latency encoding (spike) cell; produces a time-lagged set of spikes on-the-fly.

Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • tau – time constant for model used to calculate firing time (Default: 1 ms)

  • threshold – sensory input features below this threhold value will fire at final step in time of this latency coded spike train

  • first_spike_time – time of first allowable spike (ms) (Default: 0 ms)

  • linearize – should the linear latency encoding scheme be used? (otherwise, defaults to logarithmic latency encoding)

  • normalize

    normalize the latency code such that final spike(s) occur a pre-specified number of simulation steps “num_steps”? (Default: False)

    Note:

    if this set to True, you will need to choose a useful value for the “num_steps” argument (>1), depending on how many steps simulated

  • num_steps – number of discrete time steps to consider for normalized latency code (only useful if “normalize” is set to True) (Default: 1)

  • key – PRNG key to control determinism of any underlying synapses associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
property inputCompartment
classmethod inputCompartmentName()[source]
property outputCompartment
classmethod outputCompartmentName()[source]
reset(**kwargs)[source]
save(**kwargs)[source]
property timeOfLastSpike
classmethod timeOfLastSpikeCompartmentName()[source]
verify_connections()[source]
ngclearn.components.input_encoders.latencyCell.calc_spike_times_linear(data, tau, thr, first_spk_t, num_steps=1.0, normalize=False)

Computes spike times from data according to a linear latency encoding scheme.

Parameters:
  • data – pattern data to convert to spikes/times

  • tau – latency coding time constant

  • thr – latency coding threshold value

  • first_spk_t – first spike time(s) (either int or vector with same shape as spk_times; in ms)

  • num_steps – number of total time steps of simulation to consider

  • normalize – normalize the logarithmic latency code values (uses num_steps)

Returns:

projected spike times

ngclearn.components.input_encoders.latencyCell.calc_spike_times_nonlinear(data, tau, thr, first_spk_t, eps=1e-07, num_steps=1.0, normalize=False)

Computes spike times from data according to a logarithmic encoding scheme.

Parameters:
  • data – pattern data to convert to spikes/times

  • tau – latency coding time constant

  • thr – latency coding threshold value

  • first_spk_t – first spike time(s) (either int or vector with same shape as spk_times; in ms)

  • eps – small numerical error control factor (added to thr)

  • num_steps – number of total time steps of simulation to consider

  • normalize – normalize the logarithmic latency code values (uses num_steps)

Returns:

projected spike times

ngclearn.components.input_encoders.latencyCell.extract_spike(spk_times, t, mask)

Extracts a spike from a latency-coded spike train.

Parameters:
  • spk_times – spike times to compare against

  • t – current time

  • mask – prior spike mask (1 if spike has occurred, 0 otherwise)

Returns:

binary spikes, boolean mask to indicate if spikes have occurred as of yet

ngclearn.components.input_encoders.latencyCell.update_times(t, s, tols)

Updates time-of-last-spike (tols) variable.

Parameters:
  • t – current time (a scalar/int value)

  • s – binary spike vector

  • tols – current time-of-last-spike variable

Returns:

updated tols variable

ngclearn.components.input_encoders.poissonCell module

class ngclearn.components.input_encoders.poissonCell.PoissonCell(*args: Any, **kwargs: Any)[source]

Bases: Component

A Poisson cell that produces approximately Poisson-distributed spikes on-the-fly.

Parameters:
  • name – the string name of this cell

  • n_units – number of cellular entities (neural population size)

  • max_freq – maximum frequency (in Hertz) of this Poisson spike train (must be > 0.)

  • key – PRNG key to control determinism of any underlying synapses associated with this cell

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

advance_state(t, dt, **kwargs)[source]
property inputCompartment
classmethod inputCompartmentName()[source]
property outputCompartment
classmethod outputCompartmentName()[source]
reset(**kwargs)[source]
save(**kwargs)[source]
property timeOfLastSpike
classmethod timeOfLastSpikeCompartmentName()[source]
verify_connections()[source]
ngclearn.components.input_encoders.poissonCell.sample_poisson(dkey, data, dt, fmax=63.75)

Samples a Poisson spike train on-the-fly.

Parameters:
  • dkey – JAX key to drive stochasticity/noise

  • data – sensory data (vector/matrix)

  • dt – integration time constant

  • fmax – maximum frequency (Hz)

Returns:

binary spikes

ngclearn.components.input_encoders.poissonCell.update_times(t, s, tols)

Updates time-of-last-spike (tols) variable.

Parameters:
  • t – current time (a scalar/int value)

  • s – binary spike vector

  • tols – current time-of-last-spike variable

Returns:

updated tols variable

Module contents