其他分享
首页 > 其他分享> > Conv2d参数详解及复写

Conv2d参数详解及复写

作者:互联网

文档注释

def __init__(self,
             in_channels: int,
             out_channels: int,
             kernel_size: tuple[int, ...],
             stride: tuple[int, ...] = 1,
             padding: str = 0,
             dilation: tuple[int, ...] = 1,
             groups: int = 1,
             bias: bool = True,
             padding_mode: str = 'zeros',
             device: Any = None,
             dtype: Any = None) -> None
Base class for all neural network modules.
Your models should also subclass this class.
Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:
import torch.nn as nn
import torch.nn.functional as F

Conv2d要求输入(N , C , h , w )= ( 样本数 , 通道数 ,高度 ,宽度 ),Conv1d...类比

channel 通道控制组

in_channels :输入通道数,对输入的限制
out_channels : 输出通道数,要求卷积层有对应数量的卷积核,影响模型参数数量

h,w 控制组

kernel_size:卷积核维度,int => (int,int) 或 tuple
stride:卷积核移动步长,int/tuple 同上
padding:给输入h,w边界填充值,一般用于控制输出维度是否变化、上下文信息是否合并 padding_mode:填充的值
dilation:卷积区域扩张量,1:输入tensor卷积区域于卷积核一样大 2:卷积区域节点间距离1 ,依次类推 图像示例

公式推导:

源头 :Hout = (H - [(d-1)*(k-1) + k]) // Strid + 1 ,解释如下:

标签:...,tuple,int,channels,卷积,详解,输入,复写,Conv2d
来源: https://www.cnblogs.com/lhx9527/p/16260703.html