hxtorch.spiking.modules.neuron.RandomNoise

class hxtorch.spiking.modules.neuron.RandomNoise(std: Optional[Union[float, torch.Tensor]] = None, device: Optional[torch.device, None] = None)

Bases: object

Class defining gaussian random noise to mock the random noise of the membrane and adaptation state on hardware along the time axis. It is entirely defined by the standard deviation of a gaussian centered around 0, which can be sampled from.

__init__(std: Optional[Union[float, torch.Tensor]] = None, device: Optional[torch.device, None] = None)None

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

Methods

__init__([std, device])

Initialize self.

sample([size])

Sample random noise. :param size: The size of the sampled tensor. If None is passed, the resulting tensor is of the same size as self.std :returns: Returns a tensor of random values drawn from a gaussian with standard deviation self.std and mean zero.

to(device)

Set the device, the sampled tensors are going to be assigned to.

Attributes

device

std

device: Optional[torch.device, None] = None
sample(size: Optional[Union[Tuple[int], int]] = None)torch.Tensor

Sample random noise. :param size: The size of the sampled tensor. If None is passed, the

resulting tensor is of the same size as self.std

Returns

Returns a tensor of random values drawn from a gaussian with standard deviation self.std and mean zero.

std: Optional[Union[float, torch.Tensor]] = None
to(device: torch.device)Self

Set the device, the sampled tensors are going to be assigned to. :param device: The device, which is to be set.