Neuron

class Neuron[source]

Bases: Module, ABC

Base class for representing a group of neurons with a common mode of dynamics.

abstract property batchedshape: tuple[int, ...]

Batch shape of the module

Returns:

shape of the group of neurons, including batch size.

Return type:

tuple[int, …]

Raises:

NotImplementedErrorbatchedshape must be implemented by the subclass.

abstract property batchsz: int

Batch size of the neuron group.

Parameters:

value (int) – new batch size.

Returns:

present batch size.

Return type:

int

Raises:

NotImplementedErrorbatchsz must be implemented by the subclass.

abstract clear(**kwargs) None[source]

Resets neurons to their resting state.

Raises:

NotImplementedErrorclear must be implemented by the subclass.

abstract property count: int

Number of neurons in the group.

Returns:

number of neurons in the group.

Return type:

int

Raises:

NotImplementedErrorcount must be implemented by the subclass.

abstract 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

Raises:

NotImplementedErrordt must be implemented by the subclass.

extra_repr() str[source]

Returns extra information on this module.

abstract forward(inputs: Tensor, **kwargs) Tensor[source]

Runs a simulation step of the neuronal dynamics.

Parameters:

inputs (torch.Tensor) – input currents to the neurons.

Returns:

postsynaptic spikes from integration of inputs.

Return type:

torch.Tensor

Raises:

NotImplementedErrorforward must be implemented by the subclass.

abstract 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

Raises:

NotImplementedErrorrefrac must be implemented by the subclass.

abstract property shape: tuple[int, ...]

Shape of the group of neurons.

Returns:

shape of the group of neurons.

Return type:

tuple[int, …]

Raises:

NotImplementedErrorshape must be implemented by the subclass.

abstract property spike: Tensor

Action potentials last generated.

Returns:

if the corresponding neuron generated an action potential

during the prior step.

Return type:

torch.Tensor

Raises:

NotImplementedErrorspike must be implemented by the subclass.

abstract property voltage: Tensor

Membrane voltages in millivolts.

Parameters:

value (torch.Tensor) – new membrane voltages.

Returns:

present membrane voltages.

Return type:

torch.Tensor

Raises:

NotImplementedErrorvoltage must be implemented by the subclass.