1.文章原文地址

ImageNet Classification with Deep Convolutional Neural Networks

2.文章摘要

我们训练了一个大型的深度卷积神经网络用于在ImageNet LSVRC-2010竞赛中,将120万(12百万)的高分辨率图像进行1000个类别的分类。在测试集上,网络的top-1和top-5误差分别为37.5%和17.0%,这结果极大的优于先前的最好结果。这个拥有6千万(60百万)参数和65万神经元的神经网络包括了五个卷积层,其中一些卷积层后面会跟着最大池化层,以及三个全连接层,其中全连接层是以1000维的softmax激活函数结尾的。为了可以训练的更快,我们使用了非饱和神经元(如Relu,激活函数输出没有将其限定在特定范围)和一个非常高效的GPU来完成卷积运算,为了减少过拟合,我们在全连接层中使用了近期发展起来的一种正则化方式,即dropout,它被证明是非常有效的。我们也使用了该模型的一个变体用于ILSVRC-2012竞赛中,并且以top-5的测试误差为15.3赢得比赛,该比赛中第二名的top-5测试误差为26.2%。

3.网络结构

4.Pytorch实现

 import torch.nn as nn
from torchsummary import summary try:
from torch.hub import load_state_dict_from_url
except ImportError:
from torch.utils.model_zoo import load_url as load_state_dict_from_url model_urls = {
'alexnet': 'https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth',
} class AlexNet(nn.Module):
def __init__(self,num_classes=1000):
super(AlexNet,self).__init__()
self.features=nn.Sequential(
nn.Conv2d(3,96,kernel_size=11,stride=4,padding=2), #(224+2*2-11)/4+1=55
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3,stride=2), #(55-3)/2+1=27
nn.Conv2d(96,256,kernel_size=5,stride=1,padding=2), #(27+2*2-5)/1+1=27
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3,stride=2), #(27-3)/2+1=13
nn.Conv2d(256,384,kernel_size=3,stride=1,padding=1), #(13+1*2-3)/1+1=13
nn.ReLU(inplace=True),
nn.Conv2d(384,384,kernel_size=3,stride=1,padding=1), #(13+1*2-3)/1+1=13
nn.ReLU(inplace=True),
nn.Conv2d(384,256,kernel_size=3,stride=1,padding=1), #13+1*2-3)/1+1=13
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3,stride=2), #(13-3)/2+1=6
) #6*6*256=9126 self.avgpool=nn.AdaptiveAvgPool2d((6,6))
self.classifier=nn.Sequential(
nn.Dropout(),
nn.Linear(256*6*6,4096),
nn.ReLU(inplace=True),
nn.Dropout(),
nn.Linear(4096,4096),
nn.ReLU(inplace=True),
nn.Linear(4096,num_classes),
) def forward(self,x):
x=self.features(x)
x=self.avgpool(x)
x=x.view(x.size(0),-1)
x=self.classifier(x)
return x def alexnet(pretrain=False,progress=True,**kwargs):
r"""
Args:
pretrained(bool):If True, retures a model pre-trained on IMageNet
progress(bool):If True, displays a progress bar of the download to stderr
"""
model=AlexNet(**kwargs)
if pretrain:
state_dict=load_state_dict_from_url(model_urls['alexnet'],
progress=progress)
model.load_state_dict(state_dict)
return model if __name__=="__main__":
model=alexnet()
print(summary(model,(3,224,224)))
 Output:
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Conv2d-1 [-1, 96, 55, 55] 34,944
ReLU-2 [-1, 96, 55, 55] 0
MaxPool2d-3 [-1, 96, 27, 27] 0
Conv2d-4 [-1, 256, 27, 27] 614,656
ReLU-5 [-1, 256, 27, 27] 0
MaxPool2d-6 [-1, 256, 13, 13] 0
Conv2d-7 [-1, 384, 13, 13] 885,120
ReLU-8 [-1, 384, 13, 13] 0
Conv2d-9 [-1, 384, 13, 13] 1,327,488
ReLU-10 [-1, 384, 13, 13] 0
Conv2d-11 [-1, 256, 13, 13] 884,992
ReLU-12 [-1, 256, 13, 13] 0
MaxPool2d-13 [-1, 256, 6, 6] 0
AdaptiveAvgPool2d-14 [-1, 256, 6, 6] 0
Dropout-15 [-1, 9216] 0
Linear-16 [-1, 4096] 37,752,832
ReLU-17 [-1, 4096] 0
Dropout-18 [-1, 4096] 0
Linear-19 [-1, 4096] 16,781,312
ReLU-20 [-1, 4096] 0
Linear-21 [-1, 1000] 4,097,000
================================================================
Total params: 62,378,344
Trainable params: 62,378,344
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.57
Forward/backward pass size (MB): 11.16
Params size (MB): 237.95
Estimated Total Size (MB): 249.69
----------------------------------------------------------------

参考

https://github.com/pytorch/vision/tree/master/torchvision/models

AlexNet网络的Pytorch实现的更多相关文章

  1. AlexNet 网络详解及Tensorflow实现源码

    版权声明:本文为博主原创文章,未经博主允许不得转载. 1. 图片数据处理 2. 卷积神经网络 2.1. 卷积层 2.2. 池化层 2.3. 全链层 3. AlexNet 4. 用Tensorflow搭 ...

  2. 第十六节,卷积神经网络之AlexNet网络实现(六)

    上一节内容已经详细介绍了AlexNet的网络结构.这节主要通过Tensorflow来实现AlexNet. 这里做测试我们使用的是CIFAR-10数据集介绍数据集,关于该数据集的具体信息可以通过以下链接 ...

  3. 第十五节,卷积神经网络之AlexNet网络详解(五)

    原文 ImageNet Classification with Deep ConvolutionalNeural Networks 下载地址:http://papers.nips.cc/paper/4 ...

  4. Caffe训练AlexNet网络,精度不高或者为0的问题结果

    当我们使用Caffe训练AlexNet网络时,会遇到精度一值在低精度(30%左右)升不上去,或者精度总是为0,如下图所示: 出现这种情况,可以尝试使用以下几个方法解决: 1.数据样本量是否太少,最起码 ...

  5. 如何使用 libtorch 实现 AlexNet 网络?

    如何使用 libtorch 实现 AlexNet 网络? 按照图片上流程写即可.输入的图片大小必须 227x227 3 通道彩色图片 // Define a new Module. struct Ne ...

  6. pytorch实现AlexNet网络

    直接上图吧 写网络就像搭积木

  7. 群等变网络的pytorch实现

    CNN对于旋转不具有等变性,对于平移有等变性,data augmentation的提出就是为了解决这个问题,但是data augmentation需要很大的模型容量,更多的迭代次数才能够在训练数据集合 ...

  8. AlexNet网络

    AlexNet 中包含了比较新的技术点,首次在CNN中成功应用了 ReLu .Dropout和LRN等Trick. 1.成功使用了Relu作为CNN的激活函数,并验证其效果在较深的网络中超过了Sigm ...

  9. U-Net网络的Pytorch实现

    1.文章原文地址 U-Net: Convolutional Networks for Biomedical Image Segmentation 2.文章摘要 普遍认为成功训练深度神经网络需要大量标注 ...

随机推荐

  1. .mmap文件如何打开

    .mmap是一种思维导图文件的后缀,可以用Xmind软件打开.

  2. Andrew Ng机器学习课程7

    回顾 通过定义训练集S={(x(i),y(i));i=1,2,...,m}与线性决策平面(w,b)之间的function margin γ^和geometric margin γ .好的分类决策平面特 ...

  3. 【作业】Mental Rotation (模拟)

    题目链接:https://vjudge.net/contest/345791#problem/L [问题描述] Mental rotation is a difficult thing to mast ...

  4. [转帖]nginx sendfile tcp_nopush tcp_nodelay参数解释

    nginx sendfile tcp_nopush tcp_nodelay参数解释 2013-06-25 13:59:40 zmj_88888888 阅读数 20425 文章标签: nginxtcp_ ...

  5. awk简单使用

    1.awk格式 awk  [ 切割符号 ]  ' [ / pattern/ ]  函数语句 '   [ 文件名 ] 2.输出对应列 $0  全部 , $1 第一列  ,$2 第二列  ...... a ...

  6. C++语言动态创建对象

    焦头烂额的考试月终于过去了,终于有时间能停下来思考记录一下这一个月学过的东西,首先先总结一下,在自己仿写魂斗罗游戏时遇见的问题之一,人物在移动的时候如何去判断什么时候掉入水中显示水中画面,什么时候敌人 ...

  7. ubuntu 安装 Java 开发环境

    可以使用命令 -jre-headless 或者使用:   本文链接:https://blog.csdn.net/sangewuxie/article/details/80958611 本人的ubunt ...

  8. cf 869c The Intriguing Obsession

    题意:有三种三色的岛,用a,b,c来标识这三种岛.然后规定,同种颜色的岛不能相连,而且同种颜色的岛不能和同一个其他颜色的岛相连.问有多少种建桥的方法. 题解:em....dp.我们先看两个岛之间怎么个 ...

  9. Spring BeanFactory 与 FactoryBean 的区别

    BeanFactory 和 FactoryBean 都是Spring Beans模块下的接口 BeanFactory是spring简单工厂模式的接口类,spring IOC特性核心类,提供从工厂类中获 ...

  10. 解决:error LNK1169: 找到一个或多个多重定义的符号

    每一个c++项目中可以包含多个cpp文件和.h文件,不过只能有而且必须有一个cpp文件中包含main函数,否则就会报错.所以在一个c++项目中不能单独运行一个cpp文件,只能运行一个项目.如果你想一个 ...