Rate This Document
Findability
Accuracy
Completeness
Readability

Conv

Function

Conv2d: extracts local spatial features from images or feature maps.

Conv3d: performs convolution operations on 3D volume data to extract spatiotemporal features.

Prototype

torch.nn.Conv2d(
    in_channels: int,
    out_channels: int,
    kernel_size: Union[int, Tuple[int, int]],
    stride: Union[int, Tuple[int, int]] = 1,
    padding: Union[str, int, Tuple[int, int]] = 0,
    dilation: Union[int, Tuple[int, int]] = 1,
    groups: int = 1,
    bias: bool = True,
    padding_mode: str = 'zeros',
    device=None,
    dtype=None
)
torch.nn.Conv3d(
    in_channels: int,
    out_channels: int,
    kernel_size: Union[int, Tuple[int, int, int]],
    stride: Union[int, Tuple[int, int, int]] = 1,
    padding: Union[str, int, Tuple[int, int, int]] = 0,
    dilation: Union[int, Tuple[int, int, int]] = 1,
    groups: int = 1,
    bias: bool = True,
    padding_mode: str = 'zeros',
    device=None,
    dtype=None
)

Parameters

Table 1 Conv2d parameters

Parameter

Type

Mandatory (Yes/No)

Description

in_channels

int

Yes

Number of input channels

out_channels

int

Yes

Number of output channels (number of convolution kernels)

kernel_size

int/tuple

Yes

Convolution kernel size (for example, 3 or (3, 3))

stride

int/tuple

No

Stride (default value: 1)

padding

int/tuple/str

No

Border padding (default value: 0; other values include same, etc.)

dilation

int/tuple

No

Dilated convolution rate (default value: 1)

groups

int

No

Number of groups for grouped convolution (default value: 1; in_channels must be exactly divided by the number of groups)

bias

bool

No

Whether to add a bias (default value: True)

padding_mode

str

No

Padding mode, including zeros, reflect, replicate, and circular

Table 2 Conv3d parameters

Parameter

Type

Mandatory (Yes/No)

Description

in_channels

int

Yes

Number of channels of the input volume data (for example, 3 for RGB videos)

out_channels

int

Yes

Number of output channels (number of convolution kernels)

kernel_size

int/tuple

Yes

Size of the 3D convolution kernel (for example, (3, 3, 3) or 5)

stride

int/tuple

No

3D stride (default value: (1, 1, 1))

padding

int/tuple/str

No

3D border padding (default value: 0; other values include same, etc.)

dilation

int/tuple

No

Dilated 3D convolution rate (default value: 1)

groups

int

No

Number of groups for grouped convolution (default value: 1)

bias

bool

No

Whether to add a bias (default value: True)

padding_mode

str

No

Padding mode, including zeros, reflect, replicate, and circular