hxtorch.spiking.modules.synapse.Bounds

class hxtorch.spiking.modules.synapse.Bounds(lower: dataclasses.InitVar[typing.Union[float, torch.Tensor]] = <property object>, upper: dataclasses.InitVar[typing.Union[float, torch.Tensor]] = <property object>, device: Optional[torch.device, None] = None, hardware_aware: bool = True, surrogate: Callable = functools.partial(<function exponential_rolloff>, rolloff_margin=0.1, rolloff_margin_abs=0.15))

Bases: object

Class defining bounds of a finite value range and how to deal with the bounds in simulation. :param lower: The lower bound. :param upper: The upper bound. :param device: The device, the tensors containing the bounds are

transfered to.

Parameters
  • hardware_aware – When set to True, the saturation effect is considered in the backward pass of the simulation; Else, the backward function is set to be the identity function and torch.clamp() is used instead of a surrogate.

  • surrogate – Callable that implements a surrogate function for the clamp function. Is needed in case of of a hardware aware backpropagation.

__init__(lower: dataclasses.InitVar[typing.Union[float, torch.Tensor]] = <property object>, upper: dataclasses.InitVar[typing.Union[float, torch.Tensor]] = <property object>, device: Optional[torch.device, None] = None, hardware_aware: bool = True, surrogate: Callable = functools.partial(<function exponential_rolloff>, rolloff_margin=0.1, rolloff_margin_abs=0.15))None

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([lower, upper, device, …])

Initialize self.

surrogate(lower, upper, *[, rolloff_margin, …])

Wrapper for ExponentialRolloff.apply()

to(device)

Set the device of the tensors containing the bound values :param device: The device to transfer the tensors containing the bound values to.

Attributes

device

hardware_aware

lower

upper

device: Optional[torch.device, None] = None
hardware_aware: bool = True
property lower
surrogate(lower: torch.Tensor, upper: torch.Tensor, *, rolloff_margin: float = 0.1, rolloff_margin_abs: float = 0.15)torch.Tensor

Wrapper for ExponentialRolloff.apply()

to(device: torch.device)Self

Set the device of the tensors containing the bound values :param device: The device to transfer the tensors containing the

bound values to.

property upper