当前位置:网站首页>Hands-on Deep Learning_NiN
Hands-on Deep Learning_NiN
2022-08-04 21:08:00 【CV Small Rookie】
LeNet, AlexNet and VGG all share a common design pattern: extract spatial structure features through a series of convolutional layers and pooling layers; and then process the representation of features through fully connected layers.The improvement of LeNet by AlexNet and VGG mainly lies in how to expand and deepen these two modules.
However, if fully connected layers are used, the spatial structure of the representation may be discarded entirely.The network in network (NiN) provides a very simple solution: use a multi-layer perceptron on each pixel channel (in fact, add two layers of 1 x 1 convolution, because as mentioned earlier, 1 x 1The convolution is equivalent to a parameter-sharing MLP)
As you can see from the diagram, the NiN network is composed of nin_blocks, and a nin_block consists of a convolutional layer + two
1 x 1 convolution composition:
The final output cancels the use of MLP, but uses a global Pooling to change the height and width of the feature map to 1, and finally uses Flatten to flatten to get the output.
def nin_block(in_channels, out_channels, kernel_size, strides, padding):return nn.Sequential(nn.Conv2d(in_channels, out_channels, kernel_size, strides, padding),nn.ReLU(),nn.Conv2d(out_channels, out_channels, kernel_size=1), nn.ReLU(),nn.Conv2d(out_channels, out_channels, kernel_size=1), nn.ReLU())class NiN(nn.Module):def __init__(self):super(NiN, self).__init__()self.model =nn.Sequential(nin_block(1, 96, kernel_size=11, strides=4, padding=0),nn.MaxPool2d(3, stride=2),nin_block(96, 256, kernel_size=5, strides=1, padding=2),nn.MaxPool2d(3, stride=2),nin_block(256, 384, kernel_size=3, strides=1, padding=1),nn.MaxPool2d(3, stride=2),nn.Dropout(0.5),# The number of tag categories is 10nin_block(384, 10, kernel_size=3, strides=1, padding=1),nn.AdaptiveAvgPool2d((1, 1)),# Convert the 4D output to a 2D output with shape (batch size, 10)nn.Flatten())def forward(self,x):x = self.model(x)return x
The size of the output of each layer:
Sequential output shape: torch.Size([1, 96, 54, 54])MaxPool2d output shape: torch.Size([1, 96, 26, 26])Sequential output shape: torch.Size([1, 256, 26, 26])MaxPool2d output shape: torch.Size([1, 256, 12, 12])Sequential output shape: torch.Size([1, 384, 12, 12])MaxPool2d output shape: torch.Size([1, 384, 5, 5])Dropout output shape: torch.Size([1, 384, 5, 5])Sequential output shape: torch.Size([1, 10, 5, 5])AdaptiveAvgPool2d output shape: torch.Size([1, 10, 1, 1])Flatten output shape: torch.Size([1, 10])
边栏推荐
- Zero-knowledge proof notes - private transaction, pederson, interval proof, proof of ownership
- 两种白名单限流方案(redis lua限流,guava方案)
- 链队
- Matlab画图2
- C语言小笔记+题
- LINQ to SQL (Group By/Having/Count/Sum/Min/Max/Avg操作符)
- 【2022杭电多校5 1003 Slipper】多个超级源点+最短路
- dotnet 使用 lz4net 压缩 Stream 或文件
- Cryptography Series: PEM and PKCS7, PKCS8, PKCS12
- composition-api
猜你喜欢
js数据类型、节流/防抖、点击事件委派优化、过渡动画
JWT主动校验Token是否过期
[2022 Hangzhou Electric Multi-School 5 1003 Slipper] Multiple Super Source Points + Shortest Path
DICOM医学影像协议
PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning 代码解析
实战:10 种实现延迟任务的方法,附代码!
1、File对象学习
[2022 Hangzhou Electric Power Multi-School 5 1012 Questions Buy Figurines] Application of STL
【数据挖掘】搜狐公司数据挖掘工程师笔试题
五分钟入门文本处理三剑客grep awk sed
随机推荐
win10 uwp use WinDbg to debug
vim clear last search highlighting
About the state transfer problem of SAP e-commerce cloud Spartacus UI SSR
Oreo domain name authorization verification system v1.0.6 public open source version website source code
composition-api
After encountering MapStruct, the conversion between PO, DTO and VO objects is no longer handwritten
dotnet 通过 WMI 获取系统安装软件
[Data Mining] Written Exam Questions for Sohu Data Mining Engineers
链路聚合技术及VRRP
C#之app.config、exe.config和vshost.exe.config作用区别
[21 days learning challenge - kernel notes] (2), based in the device tree
数据仓库(1)什么是数据仓库,数仓有什么特点
【TypeScript】深入学习TypeScript枚举
adb shell input keyevent 模拟按键事件
PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning 代码解析
动态规划_双数组字符串
漫画 | 老板裁掉我两周后,又把我请回去,工资翻番!
After the tester with 10 years of service "naked resignation" from the big factory...
xss课堂内容复现
[AGC] Build Service 1 - Cloud Function Example