当前位置:网站首页>PyTorch随笔 - ConvMixer - Patches Are All You Need
PyTorch随笔 - ConvMixer - Patches Are All You Need
2022-07-19 20:53:00 【SpikeKing】
2022.1.24,ICLR 2022,Paper:Patches Are All You Need,即ConvMixer,卷积混合,在很多实验上,都取得很多效果。
Conv2d:
stride,窗口移动的步长,向左、向下
padding,填充,residual设置为same
dilation,膨胀、空洞,扩大范围的点,跳过一些点,选择一些点,增加感受野,不增加计算量
groups,解耦通道之间混合,降低计算,只混合部分通道,例如Depth-wise Convolution,再接一个Point-wise Convolution
Patches + Conv 代替 ViT,用patch代替像素点,Swin-Transformer效果最好
ViT:Transformer?Patch?
ViT + MLP-Mixer -> ConvMixer,以图像的patch作为输入,空间混合和通道混合分离
源码:https://github.com/locuslab/convmixer
网络结构:输入与输出一致,没有做下采样
- ConvMixer Layer写的非常Trick!
- Patch Embedding:nn.Conv2d(3, h, patch_size, stride=patch_size)
- Depthwise-Convolution:nn.Conv2d(h, h, kernel_size, groups=h, padding=“same”)
- Pointwise-Convolution:nn.Conv2d(h, h, 1)
- nn.Flatten(),向量展开
- nn.Linear(h, n_classes),FC层
Patch Embeddings:通过kernel_size
和stride都是p
GELU:Gaussian Error Linear Units,高斯错误线性单元,用于GPT-3,BERT
函数:
erf(x):error function,误差函数
效果:We name ConvMixers after their hidden dimension and depth, like ConvMixer-h/d
- h是hidden dimension,即输出channel数,d是depth,即ConvMixer Layer的层数
conv2d对比depthwise+pointwise的参数量:
import torch
import torch.nn as nn
conv_general = nn.Conv2d(3, 3, 3, padding="same")
subconv_space_mixing = nn.Conv2d(3, 3, 3, groups=3, padding="same") # Depth-wise
subconv_channel_mixing = nn.Conv2d(3, 3, 1) # Point-wise
for p in conv_general.parameters():
print(p.size(), torch.numel(p)) # weight 3x3x[3x3] = 81, bias = 3
for p in subconv_space_mixing.parameters():
print(p.size(), torch.numel(p)) # weight 3x1x[3x3] = 27, bias = 3
for p in subconv_channel_mixing.parameters():
print(p.size(), torch.numel(p)) # weight 3x3x[1x1] = 9, bias = 3
# 84 -> 27+3+9+3 = 42,参数量降低一半
边栏推荐
- Do you know MySQL mvcc
- ArrayList源码解析
- 2022 Henan Mengxin League game (2): Henan University of technology C - Zhanlong
- The LAAS protocol of defi 2.0 is the key to revitalizing the development of defi track
- July 18, 2022, village of p6722 "mcoi-01" in Luogu
- The application could not be installed: INSTALL_FAILED_USER_RESTRICTED
- 面试大厂Android开发的准备
- Essays of this week (sorted out on weekends)
- JSON format interface test process
- 目前有哪些工具可以连接PolarDB for PostgreSQL数据库并对其进行管理?
猜你喜欢
Improper use of BigDecimal caused P0 accident!
The basic operation of data tables in MySQL is very difficult. This experiment will take you through it from the beginning
微服务测试
Analyzing the innovative thinking in the curriculum of maker Education
在idea中设置文档注释的方法(图文版)
2022年找实习
MySQL查询优化
DeFi 2.0的LaaS协议Elephant,或许是你熊市下为数不多的获利手段
Y71. Chapter IV Prometheus large factory monitoring system and practice -- Prometheus server installation (II)
MySQL Authentication ‘root‘ ‘mysql_native_password‘ failed: Reading from the stream has failed
随机推荐
PMP每日一练 | 考试不迷路-7.19
Niuke multi school first game I question chiitoitsu expectation + probability DP
New research on maker Education under Information Technology
BigDecimal使用不当,造成P0事故!
[QNX Hypervisor 2.2用户手册]8.4 处理器间中断
Y71. Chapter IV Prometheus large factory monitoring system and practice -- Prometheus server installation (II)
Summary on sorting and de duplication of sets
目前有哪些工具可以连接PolarDB for PostgreSQL数据库并对其进行管理?
記錄一下十三届藍橋杯嵌入式省賽題目
20220718 安全帽、行人检测、数据集
2022 Henan Mengxin League game (2): Henan University of technology a - excellent player
sql优化相关
SQL optimization related
MySQL Authentication ‘root‘ ‘mysql_native_password‘ failed: Reading from the stream has failed
Mysql高级篇学习总结12:索引失效的11种情况
记一次爬虫逆向攻防的详细过程
渗透测试靶机实战-SQL注入getshell
English sentence pattern reference exclusive Edition - object clause
July 18, 2022, village of p6722 "mcoi-01" in Luogu
2022河南萌新联赛第(二)场:河南理工大学 C - 斩龙