本人学习pytorch主要参考官方文档和 莫烦Python中的pytorch视频教程。
后文主要是对pytorch官网的文档的总结。
代码来自pytorch官网
torch.nn.Conv2d
torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True)
卷积操作,输入矩阵大小 (N, Cin, H, W),输入矩阵大小N, Cout, Hout, Wout)
参数说明
- in_channels (int) – 输入特征矩阵的通道数 Cin
- out_channels (int) – 输出特征矩阵的通道数 Cout
- kernel_size (int or tuple) – 卷积核的大小
- stride (int or tuple, optional) – 卷积核的步长. 默认: 1
- padding (int or tuple, optional) – 边缘的扩充,使用0进行扩充 Default: 0
- dilation (int or tuple, optional) – 内核之间的距离. Default: 1
- groups (int, optional) – Number of blocked connections from input channels to output channels. Default: 1
-
bias (bool, optional) – If
True
, adds a learnable bias to the output. Default:True
torch.nn.BatchNorm2d
torch.nn.BatchNorm2d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
参数说明
- num_features – 输入特征图(N,C,H,W)中的C
- eps – a value added to the denominator for numerical stability. Default: 1e-5
- momentum – the value used for the running_mean and running_var computation. Can be set to None for cumulative moving average (i.e. simple average). Default: 0.1
- affine – a boolean value that when set to True, this module has learnable affine parameters. Default: True
- track_running_stats – a boolean value that when set to True, this module tracks the running mean and variance, and when set to False, this module does not track such statistics and always uses batch statistics in both training and eval modes. Default: True
torch.nn.Upsample
torch.nn.Upsample(size=None, scale_factor=None, mode='nearest', align_corners=None)
对输入的多通道数据进行上采样
- size (tuple ,optional)– 是输出矩阵大小([optional D_out], [optional H_out], W_out)的元组。
- scale_factor (int / tuple of python:ints, optional) – 图像宽/高/深度的倍数
- mode – (string, optional) – 上采样方法: 有nearest, linear, bilinear, bicubic and trilinear. 默认是: nearest
- align_corners (bool, optional) – 如果为true,则输入和输入tensor的角点像素对齐,从而保留这些像素的像素值。 默认值: False