hxtorch.spiking.modules.sparse_synapse.SparseSynapse

class hxtorch.spiking.modules.sparse_synapse.SparseSynapse(connections: torch.SparseTensor, experiment: Experiment, func: Union[Callable, torch.autograd.Function] = <function linear_sparse>, execution_instance: Optional[ExecutionInstance] = None, device: str = None, dtype: Type = None, transform: Callable = <function linear_saturating>)

Bases: hxtorch.spiking.modules.types.Projection

Sparse synapse layer

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

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

A sparse projection, with connections defined by non-zero entries in connections, represented sparsely on hardware.

Parameters
  • connections – A tensor of shape (in_features, out_features) defining existing connections by one-entries. Can be sparse or non-sparse.

  • experiment – Experiment to append layer to.

  • func

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

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

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

  • dtype – Data type of weight tensor.

  • transform – A function taking the modules weight tensor and transforms it into weights mappable to hardware.

Methods

__init__(connections, experiment[, func, …])

A sparse projection, with connections defined by non-zero entries in connections, represented sparsely on hardware.

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.

extra_repr()

Add additional information

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 reinitalization using torch.nn.kaiming_uniform_.

Attributes

changed_since_last_run

Getter for changed_since_last_run.

add_to_network_graph(pre: grenade.PopulationDescriptor, post: grenade.PopulationDescriptor, builder: grenade.NetworkBuilder)Tuple[grenade.ProjectionDescriptor, ]

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 population on hardware in order to represent signed hardware weights.

Parameters
  • pre – Population descriptor of pre-population.

  • post – Population descriptor of post-population.

  • builder – Greande netowrk builder to add projection to.

Returns

A tuple of grenade ProjectionDescriptors 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.

connections: torch.Tensor
extra_args: Tuple[Any]
extra_kwargs: Dict[str, Any]
extra_repr()str

Add additional information

in_features: int
out_features: int
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 reinitalization using torch.nn.kaiming_uniform_.

training: bool
weight: torch.Tensor