hxtorch.spiking.Synapse

class hxtorch.spiking.Synapse(in_features: int, out_features: int, experiment: Experiment, func: Union[Callable, torch.autograd.Function] = <function linear>, execution_instance: Optional[ExecutionInstance] = None, device: str = None, dtype: Type = None, transform: Callable = <function linear_saturating>)

Bases: hxtorch.spiking.modules.types.Projection

Synapse layer

Caveat: For execution on hardware, this module can only be used in conjunction with a subsequent Neuron module.

__init__(in_features: int, out_features: int, experiment: Experiment, func: Union[Callable, torch.autograd.Function] = <function linear>, execution_instance: Optional[ExecutionInstance] = None, device: str = None, dtype: Type = None, transform: Callable = <function linear_saturating>)None

TODO: Think about what to do with device here.

Parameters
  • in_features – Size of input dimension.

  • out_features – Size of output dimension.

  • device – Device to execute on. Only considered in mock-mode.

  • dtype – Data type of weight tensor.

  • experiment – Experiment to append layer to.

  • func

    Callable function implementing the module’s forward functionality or a torch.autograd.Function implementing the module’s forward and backward operation. Required function args:

    [input (torch.Tensor), weight (torch.Tensor)]

  • execution_instance – Execution instance to place to.

Methods

__init__(in_features, out_features, experiment)

TODO: Think about what to do with device here.

add_to_network_graph(pre, post, builder)

Adds the projection to a grenade network builder by providing the population descriptor of the corresponding pre and post population.

register_hw_entity()

Add the synapse layer to the experiment’s projections.

reset_changed_since_last_run()

Reset changed_since_last_run.

reset_parameters()

Resets the synapses weights by reinitialization using torch.nn.kaiming_uniform_.

Attributes

changed_since_last_run

Getter for changed_since_last_run.

add_to_network_graph(pre: _pygrenade_vx_network.PopulationOnNetwork, post: _pygrenade_vx_network.PopulationOnNetwork, builder: _pygrenade_vx_network.NetworkBuilder)Tuple[_pygrenade_vx_network.ProjectionOnNetwork, ]

Adds the projection to a grenade network builder by providing the population descriptor of the corresponding pre and post population. Note: This creates one inhibitory and one excitatory projection on hardware in order to represent signed hardware weights.

Parameters
  • pre – Population descriptor of pre-population.

  • post – Population descriptor of post-population.

  • builder – Grenade network builder to add projection to.

Returns

A tuple of grenade ProjectionOnNetworks holding the descriptors for the excitatory and inhibitory projection.

property changed_since_last_run

Getter for changed_since_last_run.

Returns

Boolean indicating wether module changed since last run.

output_type

alias of hxtorch.spiking.handle.SynapseHandle

register_hw_entity()None

Add the synapse layer to the experiment’s projections.

reset_changed_since_last_run()None

Reset changed_since_last_run. Sets the corresponding flag to false.

reset_parameters()None

Resets the synapses weights by reinitialization using torch.nn.kaiming_uniform_.