mlx.nn.Conv2d

目录

mlx.nn.Conv2d#

class Conv2d(in_channels: int, out_channels: int, kernel_size: int | tuple, stride: int | tuple = 1, padding: int | tuple = 0, dilation: int | tuple = 1, groups: int = 1, bias: bool = True)#

对多通道输入图像应用二维卷积。

通道预期在最后一个维度,即输入形状应为 NHWC,其中

  • N 是批量维度

  • H 是输入图像高度

  • W 是输入图像宽度

  • C 是输入通道数

参数:
  • in_channels (int) – 输入通道数。

  • out_channels (int) – 输出通道数。

  • kernel_size (inttuple) – 卷积滤波器的大小。

  • stride (inttuple, optional) – 应用滤波器时的步长大小。默认值: 1

  • padding (inttuple, optional) – 对输入进行 0 填充的位置数。默认值: 0

  • dilation (inttuple, optional) – 卷积的扩张(dilation)。

  • groups (int, optional) – 卷积的分组数。默认值: 1

  • bias (bool, optional) – 如果为 True,则在输出中添加可学习的偏置。默认值: True

方法