# AlexNet **Repository Path**: deepmodels/alex-net ## Basic Information - **Project Name**: AlexNet - **Description**: alexnet训练cifar10 - **Primary Language**: Unknown - **License**: MulanPSL-1.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-17 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AlexNet #### 介绍 alexnet训练cifar10 #### 软件架构 软件架构说明 第一层:卷积层1,输入为 224 × 224 × 3 224 \times 224 \times 3224×224×3的图像,卷积核的数量为96,论文中两片GPU分别计算48个核; 卷积核的大小为 11 × 11 × 3 11 \times 11 \times 311×11×3; stride = 4, stride表示的是步长, pad = 0, 表示不扩充边缘; 卷积后的图形大小是怎样的呢? wide = (224 + 2 * padding - kernel_size) / stride + 1 = 54 height = (224 + 2 * padding - kernel_size) / stride + 1 = 54 dimention = 96 然后进行 (Local Response Normalized), 后面跟着池化pool_size = (3, 3), stride = 2, pad = 0 最终获得第一层卷积的feature map 最终第一层卷积的输出为 第二层:卷积层2, 输入为上一层卷积的feature map, 卷积的个数为256个,论文中的两个GPU分别有128个卷积核。卷积核的大小为:5 × 5 × 48 5 \times 5 \times 485×5×48; pad = 2, stride = 1; 然后做 LRN, 最后 max_pooling, pool_size = (3, 3), stride = 2; 第三层:卷积3, 输入为第二层的输出,卷积核个数为384, kernel_size = (3 × 3 × 256 3 \times 3 \times 2563×3×256), padding = 1, 第三层没有做LRN和Pool 第四层:卷积4, 输入为第三层的输出,卷积核个数为384, kernel_size = (3 × 3 3 \times 33×3), padding = 1, 和第三层一样,没有LRN和Pool 第五层:卷积5, 输入为第四层的输出,卷积核个数为256, kernel_size = (3 × 3 3 \times 33×3), padding = 1。然后直接进行max_pooling, pool_size = (3, 3), stride = 2; 第6,7,8层是全连接层,每一层的神经元的个数为4096,最终输出softmax为1000,因为上面介绍过,ImageNet这个比赛的分类个数为1000。全连接层中使用了RELU和Dropout。 数据下载地址:[CIFAR-10](http://http://www.cs.toronto.edu/~kriz/cifar.html) ``` class AlexNet(nn.Cell): """AlexNet""" def __init__(self,num_classes=10, channel=3): super(AlexNet,self).__init__() super(AlexNet, self).__init__() self.conv1 = conv(channel, 96, 11, stride=4) self.conv2 = conv(96, 256, 5, pad_mode="same") self.conv3 = conv(256, 384, 3, pad_mode="same") self.conv4 = conv(384, 384, 3, pad_mode="same") self.conv5 = conv(384, 256, 3, pad_mode="same") self.relu = nn.ReLU() self.max_pool2d = P.MaxPool(ksize=3, strides=2) self.flatten = nn.Flatten() self.fc1 = fc_with_initialize(6 * 6 * 256, 4096) self.fc2 = fc_with_initialize(4096, 4096) self.fc3 = fc_with_initialize(4096, num_classes) def construct(self, x): x = self.conv1(x) x = self.relu(x) x = self.max_pool2d(x) x = self.conv2(x) x = self.relu(x) x = self.max_pool2d(x) x = self.conv3(x) x = self.relu(x) x = self.conv4(x) x = self.relu(x) x = self.conv5(x) x = self.relu(x) x = self.max_pool2d(x) x = self.flatten(x) x = self.fc1(x) x = self.relu(x) x = self.fc2(x) x = self.relu(x) x = self.fc3(x) return x ```