nn.Conv3d()的参数
时间: 2024-04-16 11:07:25 浏览: 16
nn.Conv3d()是PyTorch中的一个三维卷积层,其参数如下:
```python
nn.Conv3d(in_channels: int, out_channels: int, kernel_size: Union[T, Tuple[T, T, T]], stride: Union[T, Tuple[T, T, T]] = 1, padding: Union[T, Tuple[T, T, T]] = 0, dilation: Union[T, Tuple[T, T, T]] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros')
```
其中,各参数的含义如下:
- `in_channels`:输入特征图的通道数;
- `out_channels`:输出特征图的通道数;
- `kernel_size`:卷积核的大小,可以是一个整数或一个3元素元组;
- `stride`:卷积核的步长,可以是一个整数或一个3元素元组;
- `padding`:输入特征图的边缘填充大小,可以是一个整数或一个3元素元组;
- `dilation`:卷积核的空洞大小,可以是一个整数或一个3元素元组;
- `groups`:输入通道数和输出通道数之间的分组数量;
- `bias`:是否使用偏置项;
- `padding_mode`:填充模式,可以是`'zeros'`、`'reflect'`或`'replicate'`。
需要注意的是,输入特征图的形状为`(batch_size, in_channels, depth, height, width)`。输出特征图的形状为`(batch_size, out_channels, out_depth, out_height, out_width)`,其中:
$$
\text{out\_depth} = \left\lfloor \frac{\text{depth} + 2 \times \text{padding}[0] - \text{dilation}[0] \times (\text{kernel\_size}[0]-1) - 1}{\text{stride}[0]} + 1 \right\rfloor
$$
$$
\text{out\_height} = \left\lfloor \frac{\text{height} + 2 \times \text{padding}[1] - \text{dilation}[1] \times (\text{kernel\_size}[1]-1) - 1}{\text{stride}[1]} + 1 \right\rfloor
$$
$$
\text{out\_width} = \left\lfloor \frac{\text{width} + 2 \times \text{padding}[2] - \text{dilation}[2] \times (\text{kernel\_size}[2]-1) - 1}{\text{stride}[2]} + 1 \right\rfloor
$$