hxtorch.perceptron.nn.ConvNd

class hxtorch.perceptron.nn.ConvNd(num_sends: Optional[numbers.Integral] = None, wait_between_events: numbers.Integral = 5, mock: bool = False, *, input_transform: Optional[Callable[[torch.Tensor], torch.Tensor]] = None, weight_transform: Optional[Callable[[torch.Tensor], torch.Tensor]] = <function clamp_weight_>)

Bases: hxtorch.perceptron.nn.MACLayer, torch.nn.modules.conv._ConvNd

Base class for n-dimensional convolution.

__init__(num_sends: Optional[numbers.Integral] = None, wait_between_events: numbers.Integral = 5, mock: bool = False, *, input_transform: Optional[Callable[[torch.Tensor], torch.Tensor]] = None, weight_transform: Optional[Callable[[torch.Tensor], torch.Tensor]] = <function clamp_weight_>)
Parameters
  • num_sends – Number of sends of the input. Values greater than 1 result in higher output to the neurons and increases the s/n ratio. For None this is automatically adjusted during initialization.

  • wait_between_events – Wait time between two successive vector inputs, in FPGA clock cycles. Shorter wait time can lead to saturation of the synaptic input.

  • mock – Enable mock mode.

  • input_transform – Function that receives the input and returns a tensor to be used as input to the chip.

  • weight_transform – Function that receives the weight and returns a tensor to be used as weight matrix on the chip.

Methods

forward(input)

Defines the computation performed at every call.

Attributes

bias: Optional[torch.Tensor]
dilation: Tuple[int, ]
forward(input)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

groups: int
in_channels: int
kernel_size: Tuple[int, ]
out_channels: int
output_padding: Tuple[int, ]
padding: Union[str, Tuple[int, ]]
padding_mode: str
stride: Tuple[int, ]
transposed: bool
weight: torch.Tensor