经典CNN卷积神经网络架构全解析:LeNet、AlexNet、GoogleNet、ResNet、DenseNet
卷积神经网络 (CNN)是深度学习中的一种神经网络架构,用于从结构化数组中识别模式。然而,多年来,CNN 架构已经发展起来。基本 CNN 架构的许多变体已经开发出来,从而为不断发展的深度学习领域带来了惊人的进步。
下面,让我们讨论一下 CNN 架构是如何随着时间的推移而发展和成长的。
1.LeNet-5
-
第一个LeNet-5架构是最广为人知的CNN架构。它于1998年推出,广泛用于手写方法数字识别。
-
LeNet-5 有 2 个卷积层和 3 个完整层。
-
这个LeNet-5架构有60,000个参数。结构如下:

-
LeNet-5 能够处理需要更大、更多 CNN 卷积层的更高分辨率图像。
-
leNet-5 技术是通过所有计算资源的可用性来衡量的
LeNet-5网络构建
LeNet-5 代码示例
import torch
from torchsummary import summary
import torch.nn as nn
import torch.nn.functional as F class LeNet5(nn.Module):
def __init__(self):
# Call the parent class's init method
super(LeNet5, self).__init__() # First Convolutional Layer
self.conv1 = nn.Conv2d(in_channels=1, out_channels=6, kernel_size=5, stride=1) # Max Pooling Layer
self.pool = nn.MaxPool2d(kernel_size=2, stride=2) # Second Convolutional Layer
self.conv2 = nn.Conv2d(in_channels=6, out_channels=16, kernel_size=5, stride=1) # First Fully Connected Layer
self.fc1 = nn.Linear(in_features=16 * 5 * 5, out_features=120) # Second Fully Connected Layer
self.fc2 = nn.Linear(in_features=120, out_features=84) # Output Layer
self.fc3 = nn.Linear(in_features=84, out_features=10) def forward(self, x):
# Pass the input through the first convolutional layer and activation function
x = self.pool(F.relu(self.conv1(x))) # Pass the output of the first layer through
# the second convolutional layer and activation function
x = self.pool(F.relu(self.conv2(x))) # Reshape the output to be passed through the fully connected layers
x = x.view(-1, 16 * 5 * 5) # Pass the output through the first fully connected layer and activation function
x = F.relu(self.fc1(x)) # Pass the output of the first fully connected layer through
# the second fully connected layer and activation function
x = F.relu(self.fc2(x)) # Pass the output of the second fully connected layer through the output layer
x = self.fc3(x) # Return the final output
return x lenet5 = LeNet5()
print(lenet5)
输出:
LeNet5(
(conv1): Conv2d(1, 6, kernel_size=(5, 5), stride=(1, 1))
(pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(conv2): Conv2d(6, 16, kernel_size=(5, 5), stride=(1, 1))
(fc1): Linear(in_features=400, out_features=120

8888

被折叠的 条评论
为什么被折叠?



