CoarseNetd的网络结构卷积层详细公式
时间: 2023-07-08 20:04:18 浏览: 81
CoarseNetd是一个用于图像分类任务的卷积神经网络,其网络结构如下所示:
```
CoarseNetd(
(conv1): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(bn1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(maxpool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(layer1): Sequential(
(0): BasicBlock(
(conv1): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(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))
(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(1): BasicBlock(
(conv1): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
(bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(downsample): Sequential(
(0): Conv2d(64, 128, kernel_size=(1, 1), stride=(2, 2))
(1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(2): BasicBlock(
(conv1): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(downsample): Sequential(
(0): Conv2d(128, 256, kernel_size=(1, 1), stride=(2, 2))
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(3): BasicBlock(
(conv1): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
(bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(downsample): Sequential(
(0): Conv2d(256, 512, kernel_size=(1, 1), stride=(2, 2))
(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
)
(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))
(fc): Linear(in_features=512, out_features=10, bias=True)
)
```
其中,`Conv2d`表示卷积层,其参数为输入通道数、输出通道数、卷积核大小、卷积步长和填充大小。`BatchNorm2d`表示批量归一化层,`ReLU`表示ReLU激活函数,`MaxPool2d`表示最大池化层,`AdaptiveAvgPool2d`表示自适应平均池化层,`Linear`表示全连接层。
具体地,`conv1`的卷积核大小为3x3,输入通道数为3,输出通道数为32,卷积步长为1,填充大小为1。`layer1`中包含4个`BasicBlock`,每个`BasicBlock`包含两个卷积层和一个批量归一化层。其中,第一个卷积层的卷积核大小为3x3,输入通道数为32(或上一个`BasicBlock`的输出通道数),输出通道数为64,卷积步长为1,填充大小为1;第二个卷积层的卷积核大小为3x3,输入通道数为64,输出通道数为64,卷积步长为1,填充大小为1。`layer1`中第一个`BasicBlock`的输入通道数和输出通道数不一致,因此需要添加一个`downsample`模块,其包含一个卷积层和一个批量归一化层,用于将输入的通道数变为输出通道数。`layer1`中后面的三个`BasicBlock`的输入通道数和输出通道数均为64、128、256和512,分别对应着四个下采样操作,即前三个`BasicBlock`的卷积层步长为2,将输入大小缩小为原来的一半,而最后一个`BasicBlock`的步长为1,大小不变。`avgpool`为自适应平均池化层,用于将最后卷积层的输出特征图转化为定长向量。`fc`为全连接层,输入大小为512,输出大小为10,用于进行分类。
阅读全文