pytagi.nn.conv2d#

Classes#

Conv2d

Applies a 2D convolution operation.

Module Contents#

class pytagi.nn.conv2d.Conv2d(in_channels: int, out_channels: int, kernel_size: int, bias: bool = True, stride: int = 1, padding: int = 0, padding_type: int = 1, in_width: int = 0, in_height: int = 0, gain_weight: float = 1.0, gain_bias: float = 1.0, init_method: str = 'He')[source]#

Bases: pytagi.nn.base_layer.BaseLayer

Applies a 2D convolution operation.

This layer performs a convolution operation, which is a fundamental building block in convolutional neural networks (CNNs). It slides a kernel (or filter) over an input tensor to produce an output tensor.

Parameters:
  • in_channels (int) – Number of input channels.

  • out_channels (int) – Number of output channels.

  • kernel_size (int) – Size of the convolutional kernel.

  • bias (bool) – Whether to include a learnable bias term. Defaults to True.

  • stride (int) – The step size of the kernel. Defaults to 1.

  • padding (int) – Amount of zero-padding added to the input. Defaults to 0.

  • padding_type (int) – Type of padding. Defaults to 1 (likely ‘zeros’ or similar).

  • in_width (int) – Input width. If 0, it might be inferred or set by the backend. Defaults to 0.

  • in_height (int) – Input height. If 0, it might be inferred or set by the backend. Defaults to 0.

  • gain_weight (float) – Initial value for the gain (scale) parameter of weights. Defaults to 1.0.

  • gain_bias (float) – Initial value for the gain (scale) parameter of biases. Defaults to 1.0.

  • init_method (str) – Method used for initializing weights. Defaults to “He”.

Initializes the Conv2d layer.

get_layer_info() str[source]#

Retrieves detailed information about the Conv2d layer.

Returns:

A string containing the layer’s information.

Return type:

str

get_layer_name() str[source]#

Retrieves the name of the Conv2d layer.

Returns:

The name of the layer.

Return type:

str

init_weight_bias()[source]#

Initializes the learnable weight (kernel) and bias parameters of the convolutional layer. This initialization is delegated to the C++ backend using the ‘init_method’ specified (e.g., “He”).