hxtorch.spiking.transforms.encode.PixelsToSpikeTimes

class hxtorch.spiking.transforms.encode.PixelsToSpikeTimes(tau=20, threshold=0.2, t_max=1.0, epsilon=1e-07)

Bases: torch.nn.modules.module.Module

Encode image by spike trains

__init__(tau=20, threshold=0.2, t_max=1.0, epsilon=1e-07)None

Initialize a pixel to spike time transformation.

Parameters
  • tau – Stretching factor of pixel to spike-time transformation. Lager values correspond to later spike times.

  • threshold – The threshold under which a pixel is considered non-spiking (resp. spike at time t_max).

  • t_max – Maximum spike time.

  • epsilon – Safety margin to prevent zero-division.

Methods

__init__([tau, threshold, t_max, epsilon])

Initialize a pixel to spike time transformation.

forward(pic)

Turns an image into a spike representation.

Attributes

forward(pic: torch.Tensor)torch.Tensor

Turns an image into a spike representation. Image pixels >= threshold are assigned a spike time according to:

t_spike = au * log(pixel / (pixel - threshold))

If a pixel is < threshold it gets assigned the spike time t_max.

Parameters

pic – Image to transform into spike trains. Has to be of shape (color_channel, width, height).

Returns

Returns the image represented by spike trains, given as a tensor of shape (spike_time, color_channel, width, height).

training: bool