class sinabs.backend.dynapcnn.dvs_layer.DVSLayer(input_shape: Tuple[int, int], pool: Tuple[int, int] = (1, 1), crop: Tuple[Tuple[int, int], Tuple[int, int]] | None = None, merge_polarities: bool = False, flip_x: bool = False, flip_y: bool = False, swap_xy: bool = False, disable_pixel_array: bool = True)[source]#

DVSLayer representing the DVS pixel array on chip and/or the pre-processing. The order of processing is as follows MergePolarity -> Pool -> Cut -> Flip.

  • input_shape; – Shape of input (height, width)

  • pool (Tuple[int, int]) – Sum pooling kernel size (height, width)

  • crop (Tuple[Tuple[int, int], Tuple[int, int]] | None) – Crop the input to the given ROI ((top, bottom), (left, right))

  • merge_polarities (bool) – If true, events from both polarities will be merged.

  • flip_x (bool) – Flip the X axis

  • flip_y (bool) – Flip the Y axis

  • swap_xy (bool) – Swap X and Y dimensions

  • disable_pixel_array (bool) – Disable the pixel array. This is useful if you want to use the DVS layer for input preprocessing.

  • input_shape (Tuple[int, int])


Define the computation performed at every call.

Should be overridden by all subclasses.


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.

classmethod from_layers(input_shape: Tuple[int, int, int], pool_layer: SumPool2d | None = None, crop_layer: Crop2d | None = None, flip_layer: FlipDims | None = None, disable_pixel_array: bool = True) DVSLayer[source]#

Alternative factory method. Generate a DVSLayer from a set of torch layers.

  • input_shape (Tuple[int, int, int]) – (channels, height, width)

  • pool_layer (SumPool2d | None) – SumPool2d layer

  • crop_layer (Crop2d | None) – Crop2d layer

  • flip_layer (FlipDims | None) – FlipDims layer

  • disable_pixel_array (bool) – Whether pixel array of new DVSLayer should be disabled.

Return type:


get_config_dict() dict[source]#
Return type:


get_flip_dict() dict[source]#

Configuration dictionary for x, y flip.

Return type:


get_output_shape() Tuple[int, int, int][source]#

Output shape of the layer.

Return type:

(channel, height, width)

get_output_shape_after_pooling() Tuple[int, int, int][source]#

Get the shape of data just after the pooling layer.

Return type:

(channel, height, width)

get_output_shape_dict() dict[source]#

Configuration dictionary for output shape.

Return type:


get_pooling() Tuple[int, int][source]#

Pooling kernel shape.

Return type:

(ky, kx)

get_roi() Tuple[Tuple[int, int], Tuple[int, int]][source]#

The coordinates for ROI. Note that this is not the same as crop parameter passed during the object construction.

Return type:

((top, bottom), (left, right))

get_swap_xy() bool[source]#

True if XY has to be swapped.

Return type:


property input_shape_dict: dict#

The configuration dictionary for the input shape.

Return type: