ExactNeuron

class ExactNeuron(shape: Sequence[int], step_time: float, *, rest_v: float, thresh_v: float, batch_size: int = 1)[source]

Bases: InfernoNeuron

Simple neuron class useful for getting predictable outputs for visualization.

An action potential will be generated if the input to forward() is positive, unless an override``boolean tensor is given, in which case that will be used instead. Membrane voltages will be set to ``thresh_v if a spike was generated, and otherwise will be set to rest_v.

Parameters:
  • shape (Sequence[int]) – shape of the group of neurons being simulated.

  • step_time (float) – length of a simulation time step, \(\Delta t\), in \(\text{ms}\).

  • rest_v (float) – membrane potential difference at equilibrium, \(V_\text{rest}\), in \(\text{mV}\).

  • thresh_v (float) – membrane voltage at which action potentials are generated, in \(\text{mV}\).

  • batch_size (int, optional) – size of input batches for simulation. Defaults to 1.

Note

Unlike in an actual neuron model, rest_v and thresh_v don’t control any spiking behavior—these just change the presentation of the membrane voltage.

clear(**kwargs) None[source]

Resets neurons to their resting state.

property dt: float

Length of the simulation time step, in milliseconds.

Parameters:

value (float) – new simulation time step length.

Returns:

present simulation time step length.

Return type:

float

forward(inputs: Tensor, override: Tensor | None = None, **kwargs) Tensor[source]

Runs a simulation step of the neuronal dynamics.

Parameters:
  • inputs (torch.Tensor) – presynaptic currents, \(I(t)\), in \(\text{nA}\).

  • override (optional, torch.Tensor | None) – tensor of spikes to use for output if spiking output should not be based on inputs. Defaults to None.

Returns:

if the corresponding neuron generated an action potential.

Return type:

torch.Tensor

property refrac: Tensor

Remaining refractory periods, in milliseconds.

Parameters:

value (torch.Tensor) – new remaining refractory periods.

Returns:

present remaining refractory periods.

Return type:

torch.Tensor

Note

ExactNeuron doesn’t support refractory periods. The getter will always return a tensor of zeros and the setter will do nothing.

property spike: Tensor

Action potentials last generated.

Returns:

if the corresponding neuron generated an action potential

during the prior step.

Return type:

torch.Tensor

property voltage: Tensor

Membrane voltages in millivolts.

Parameters:

value (torch.Tensor) – new membrane voltages.

Returns:

present membrane voltages.

Return type:

torch.Tensor

Note

ExactNeuron derives membrane voltage from action potentials. Therefore the setter will do nothing.