InfernoSynapse¶
- class InfernoSynapse(shape: tuple[int, ...] | int, step_time: float, delay: float, batch_size: int, inplace: bool)[source]¶
Bases:
DelayedMixin,BatchShapeMixin,SynapseBase class for representing synapses included in the Inferno library.
Unlike
Neuronwhich only defines an interface, this usesBatchShapeMixinandDelayedMixinto 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
RecordTensorattributes should be performed with in-place operations.
- clear(**kwargs) None[source]¶
Resets synapses to their resting state.
- Raises:
NotImplementedError –
clearmust 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:
- Raises:
NotImplementedError –
currentmust 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:
- Raises:
NotImplementedError –
current_atmust be implemented by the subclass.
- property delay: float¶
Maximum supported delay, in milliseconds.
- Returns:
maximum supported delay.
- Return type:
- 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:
- Raises:
NotImplementedError –
forwardmust 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:
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:
NotImplementedError –
partialconstructormust be implemented by the subclass.- Returns:
partial constructor for synapses of a given class.
- Return type:
- property spike: Tensor¶
Spike input to the synapses at present.
- Parameters:
value (torch.Tensor) – new spike input.
- Returns:
present spike input.
- Return type:
- Raises:
NotImplementedError –
spikemust 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:
- Raises:
NotImplementedError –
spike_atmust be implemented by the subclass.