beatmup.nnets.Conv2D

class beatmup.nnets.Conv2D

2D convolution operation computed on GPU. Has 2 inputs: main and residual (detailed below), and a single output. Constraints:

  • Input and output are 3D tensors with values in [0, 1] range sampled over 8 bits.

  • Number of input feature maps is 3 or a multiple of 4.

  • Number of output feature maps is a multiple of 4.

  • For group convolutions, each group contains a multiple of 4 input channels and a multiple of 4 output channels, or exactly 1 input and 1 output channel (i.e., depthwise).

  • Kernels are of square shape.

  • Strides are equal along X and Y.

  • Dilations are equal to 1.

  • If an image is given on input (3 input feature maps), only valid padding is supported.

  • An activation function is always applied on output.

Raspberry Pi-related constraints:

  • Pi cannot sample more than 256 channels to compute a single output value. Actual practical limit is yet lower: something about 128 channels for pointwise convolutions and less than 100 channels for bigger kernels. When the limit is reached, Pi OpenGL driver reports an out of memory error (0x505).

Features:

  • Bias addition integrated.

  • An optional residual input is available: a tensor of output shape added to the convolution result before applying the activation function.

__init__(self: beatmup.nnets.Conv2D, name: str, kernel_size: int, num_input_channels: int, num_output_channels: int, stride: int = 1, padding: beatmup.nnets.Padding = <Padding.VALID: 1>, use_bias: bool = True, num_groups: int = 1, activation: beatmup.nnets.ActivationFunction = <ActivationFunction.DEFAULT: 0>) None

Instantiates a 2D convolution operation.

Parameters:
  • name – operation name.

  • kernel_size – convolution kernel size.

  • num_input_channels – number of input feature map channels (input depth).

  • num_output_channels – number of output feature map channels (output depth).

  • stride – convolution stride.

  • padding – padding policy.

  • use_bias – if true, the bias addition is enabled. The bias vector is searched in the model data.

  • num_groups – number of convolution groups to get a group/depthwise convolution.

  • activation – activation function applied to the operation output.

Methods

__init__(self, name, kernel_size, ...)

Instantiates a 2D convolution operation.

Attributes

bias_chunk_suffix

filters_chunk_suffix

input_count

Number of operation inputs

name

Operation name

output_count

Number of operation outputs

use_bias

Returns true if bias addition is enabled