Resnet网络详细结构(针对Cifar10)

时间:2024-01-16 10:32:08

Resnet网络详细结构(针对Cifar10)

结构

Resnet网络详细结构(针对Cifar10)

具体结构(Pytorch)

  1. conv1

    (conv1): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (relu): ReLU(inplace=True)
    (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
    • Conv2d

      • Conv2d(in_channels, out_channels, kernel_size, stride=1,padding=0, dilation=1, groups=1,bias=True, padding_mode=‘zeros’)
        (输入通道,输出通道数,F:卷积核的大小,S:步长,P:padding,dilation:卷积核的间隔,空洞卷积)
      • 卷积核维度计算公式:

      \[W_o = (W_i-F+2P)/S+1
      \]
    • BatchNorm2d:批归一化(Batch Normalization)的目的是使我们的一批(Batch)的feature map满足均值为0,方差为1的分布规律

      • BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True,track_running_stats=True)
    • ReLU:激活函数

    • MaxPool2d:最大池化,下采样

  2. layer1

    (layer1): Sequential(
    (0): BasicBlock(
    (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (relu): ReLU(inplace=True)
    (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    )
    (1): BasicBlock(
    (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (relu): ReLU(inplace=True)
    (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)))
  3. layer3:……

  4. layer4:……

  5. avgpool

    • AdaptiveAvgPool2d :自适应平均池化

      • torch.nn.AdaptiveAvgPool1d(output_size)
      • 对输入进行自适应平均池化,输出指定为output_size,特征维数不变,根据输出大小计算核池化的核大小,步长

  6. fc:全连接

(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))
(fc): Linear(in_features=512, out_features=10, bias=True)