主要介绍LeNet 与 AlexNet,还 涉及到dropout, maxpooling, relu等概念
In this notebook we will motivate and implement from scratch two Convolutional Neural Networks (CNNs) that had big impacts on the field of Deep Learning. Namely, we will look at LeNet-5 (Yann LeCunn et al., 1989), which is considered one of the first CNNs ever and also AlexNet (Alex Krizhevsky et al., 2012), which won the 2012 ImageNet competition by an impressive marging and introduced many techniques that are considered state of the art even today (e.g. dropout, maxpooling, relu, etc).
These networks offer a glimpse into the history of computer vision, including the early trends and challenges. Limited computational resources in particular have led to the rapid innovation we’ve seen in the last few decades.
![]()
介绍概念
Convolutional layer
通过卷积核提取特征

Pooling layer
让特征图大小缩小(历史遗留问题,这里也称为下采样,有用池化层进行下采样,而现在用卷积层下采样),深层的视野“变大”
max pooling具有平移不变性,而 average pooling 仅可缩小特征图大小
故AlexNet中 Maxpooling is being used instead of average pooling.

对于池化让感受视野变大的理解

Activation layer
非线性激活函数,enable the model to learn more complex relationships
AlexNet中使用ReLU which makes training much faster.
Dense layer ( fully connected layer)
every neuron in the previous layer is connected to the current layer through weights and biases.
Dropout
随机断开几个神经网络连接,使得结果不仅仅依赖于哪几个神经元(也就是防止过拟合)
由AlexNet引入

one-hot编码
原始字符标签,第一列是序号,第二列是标签

one-hot
第一列是序号,0-9中显示为1的是标签,eg:第0行1处显示1,则说明该行标签为1;第0、41999行9处显示1,则说明该行标签为9

TensorFlow起手
| |
LeNet5
| |
加载数据集、数据集标准化、划分数据集、one-hot编码
| |
训练
| |
评估
| |
测试结果

获取损失和精确度
| |
Dense层处理后参数剧增

参数计算公式:

AlexNet
为了适配CIFAR-10的10分类任务,对输入大小、卷积核大小和数量、步幅、优化器、填充、每层神经元个数,进行了更改,每个卷积后加入一个BatchNormalization,卷积中加入regularizers。
这种修改称为结构定制。
| |
处理测试集
| |
训练
| |
绘制相关数据曲线
| |
展示测试
| |
感觉PyTorch的封装程度没有TensorFlow高。