InfernoSynapse

class InfernoSynapse(shape: tuple[int, ...] | int, step_time: float, delay: float, batch_size: int, inplace: bool)[source]

Bases: DelayedMixin, BatchShapeMixin, Synapse

Base class for representing synapses included in the Inferno library.

Unlike Neuron which only defines an interface, this uses BatchShapeMixin and DelayedMixin to work with the included mixins to automatically reshape batch-size dependent buffers and parameters, and to manage recorded history for delay-stored buffers and parameters.

Parameters:
  • shape (tuple[int, ...] | int) – shape of the group of synapses, excluding the batch dim.

  • step_time (float) – length of a simulation time step, in \(ms\).

  • delay (float) – maximum supported delay, in \(ms\).

  • batch_size (int) – size of the batch dimension.

  • inplace (bool) – if write operations on RecordTensor attributes should be performed with in-place operations.

clear(**kwargs) None[source]

Resets synapses to their resting state.

Raises:

NotImplementedErrorclear must be implemented by the subclass.

property current: Tensor

Currents of the synapses at present, in nanoamperes.

Parameters:

value (torch.Tensor) – new synapse currents.

Returns:

present synaptic currents.

Return type:

torch.Tensor

Raises:

NotImplementedErrorcurrent must be implemented by the subclass.

current_at(selector: Tensor) Tensor[source]

Currents, in nanoamperes, at times specified by delays, in milliseconds.

Parameters:

selector (torch.Tensor) – delays for selection of currents.

Returns:

synaptic currents at the specified times.

Return type:

torch.Tensor

Raises:

NotImplementedErrorcurrent_at must be implemented by the subclass.

property delay: float

Maximum supported delay, in milliseconds.

Returns:

maximum supported delay.

Return type:

float

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, **kwargs) Tensor[source]

Runs a simulation step of the synaptic dynamics.

Parameters:

*inputs (torch.Tensor) – tensors shaped like the synapse.

Returns:

synaptic currents after integration of the inputs.

Return type:

torch.Tensor

Raises:

NotImplementedErrorforward must be implemented by the subclass.

property inplace: bool

If write operations should be performed in-place.

Parameters:

value (bool) – if write operations should be performed in-place.

Returns:

if write operations should be performed in-place.

Return type:

bool

Note

Generally if gradient computation is required, this should be set to False.

classmethod partialconstructor(*args, **kwargs) SynapseConstructor[source]

Returns a function with a common signature for synapse construction.

Raises:

NotImplementedErrorpartialconstructor must be implemented by the subclass.

Returns:

partial constructor for synapses of a given class.

Return type:

SynapseConstructor

property spike: Tensor

Spike input to the synapses at present.

Parameters:

value (torch.Tensor) – new spike input.

Returns:

present spike input.

Return type:

torch.Tensor

Raises:

NotImplementedErrorspike must be implemented by the subclass.

spike_at(selector: Tensor) Tensor[source]

Spikes, as booleans, at times specified by delays, in milliseconds.

Parameters:

selector (torch.Tensor) – delays for selection of spikes.

Returns:

spike input at the given times.

Return type:

torch.Tensor

Raises:

NotImplementedErrorspike_at must be implemented by the subclass.