经典卷积网络:AlexNet、ZFNet、VGG、GoogleNet、ResNet

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言

文章主要内容:经典卷积网络的学习总结

—`

一、AlexNet

1、理论介绍

AlexNet验证了深度卷积神经网络的高效性
在这里插入图片描述
文章的主要贡献有六点:
① 提出了一种卷积层加全连接层的卷积神经网络
② 首次使用ReLU函数作为神经网络的激活函数
③ 首次提出使用Dropout正则化来控制过拟合
④ 使用加入动量的小批量梯度下降算法加速了训练过程的收敛
⑤ 使用数据增强策略极大地抑制了训练过程的过拟合
⑥ 利用GPU的并行计算能力,加速了网络的训练与推断

网络结构:
CONV1
MAX_POOL1
NORM1
CONV2
MAX_POOL2
NORM2
CONV3
CONV4
CONV5
MAX_POOL3
FC6
FC7
FC8

第一层(CONV1):96个11x11卷积核,步长为4,没用零填充。第一个卷积层提取了96种结构的响应信息,得到了96个特征响应图(双GPU,每个为48);特征图每个元素经过ReLU函数操作后输出

Max_POOL1:窗口大小3x3,步长为2
作用:降低特征图尺寸
输出尺寸:(55-3)/2+1=27
特征图个数:96
参数个数:0

NORM1(局部响应归一化层):现在用的很少

第二层(CONV2):256个5x5卷积核,步长为1,使用零填充p=2
输出尺寸:27x27x256
特征图个数:256

Max_POOL2:最大池化层进一步缩小特征图尺寸

第三、四层(CONV3、CONV4:384个3x3卷积核,步长为1,使用零填充p=2
输入尺寸:(27-3)/1+1 =13 13x13x256
输出尺寸:13x13x384
特征图个数:384

第五层(CONV5):256个3x3卷积核,步长为1,使用零填充p=1

Max_POOL3:最大池化层进一步缩小特征图尺寸:(13-3)/2+1
输出尺寸:6x6x256
输出:特征响应图组

第六-八层(FC6、FC7、FC8):全连接网络分类
FC6输入:6x6x256=9216维向量
输出:图像类别的概率
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2、代码实现

model部分

import torch.nn as nn
import torch

class AlexNet(nn.Module):
    def __init__(self, num_classes=1000, init_weights=False):
        super(AlexNet, self).__init__()
        self.features = nn.Sequential(
            nn.Conv2d(3, 48, kernel_size=11, stride=4, padding=2),  # input[3, 224, 224]  output[48, 55, 55]
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),                  # output[48, 27, 27]
            nn.Conv2d(48, 128, kernel_size=5, padding=2),           # output[128, 27, 27]
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),                  # output[128, 13, 13]
            nn.Conv2d(128, 192, kernel_size=3, padding=1),          # output[192, 13, 13]
            nn.ReLU(inplace=True),
            nn.Conv2d(192, 192, kernel_size=3, padding=1),          # output[192, 13, 13]
            nn.ReLU(inplace=True),
            nn.Conv2d(192, 128, kernel_size=3, padding=1),          # output[128, 13, 13]
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),                  # output[128, 6, 6]
        )
        self.classifier = nn.Sequential(
            nn.Dropout(p=0.5),
            nn.Linear(128 * 6 * 6, 2048),
            nn.ReLU(inplace=True),
            nn.Dropout(p=0.5),
            nn.Linear(2048, 2048),
            nn.ReLU(inplace=True),
            nn.Linear(2048, num_classes),
        )
        if init_weights:
            self._initialize_weights()

    def forward(self, x):
        x = self.features(x)
        x = torch.flatten(x, start_dim=1)
        x = self.classifier(x)
        return x

    def _initialize_weights(self):
        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
                if m.bias is not None:
                    nn.init.constant_(m.bias, 0)
            elif isinstance(m, nn.Linear):
                nn.init.normal_(m.weight, 0, 0.01)
                nn.init.constant_(m.bias, 0)


二、ZFNet

三、VGG

四、GoogleNet

五、ResNet

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

odd~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值