当前位置:网站首页>yolov5 improvement (1) Add attention focus mechanism
yolov5 improvement (1) Add attention focus mechanism
2022-08-02 14:19:00 【weixin_50862344】
(1) Self-attention mechanism
What I want to learn is the attention mechanism, but it seems to be running out of bounds at first, and I learned the self-attention mechanism.Not to mention, it's pretty good.
NTU Li Hongyi Self-Attention Mechanism
input: vector set
muti-head: may have different connections
Application in image:
Think of rgb on a pixel as a vector
Applications on the model include: ①self-attention GAN
②DETR
Comparison of CNN and Self-attention:
CNN only considers the receptive field, and Self-attention considers the overall situation.So think of cnn as a small (simplified) Self-attention
②Small data volume is superior to CNN, while large volume Self-attention will surpass CNN
Li Hongyi's statement for the reason is: Self-Attention is more elastic, CNN is less elastic
RNN&SA
①SA is parallelized, RNN cannot parallel words
②Data memory
(2) Attention mechanism
The next step is the attention mechanism (Attention)
First upload the information first
pytorch application:
First go to the information
In fact, it is on csdnThere are online courses but poor children really have no money to spend recently, but we can still learn according to his framework
1. Understand the attention mechanism
Attention is divided into four basic types according to the different dimensions of attention: channel attention, spatial attention, temporal attention and branch attention
,And two combined attentions: channel-spatial attention and spatial-temporal attention
.
spatial: space
temporal: time
> Draw a 3D coordinate axis like this:
2. Enter the attention module
If you encounter problems, please look at B-led lesson
The functions that this Xiaobai does not know, the example is better to understand
1) cat: splice
2) view: change the arrangement of cols and rows
3) torch.mean channel average &torch.maxChannel max
torch.nn.AdaptiveAvgPool2d(output_size
): Provides a 2-dimensional adaptive average pooling operation. For any input size input, the output size can be specified as H*Wp>
Compared with global average pooling, it can be understood that the slicing method is different!!!
The attention mechanism is a plug-and-play module that can theoretically be placed behind any feature layer.
Since placing on thebackbone will make the pretrained weights of the network unavailable
, apply the attention mechanism to enhancing the feature extraction network
How come someone even wrote the actual combat?Still so well written?yolov5 adds an attention-focusing mechanismdownloaded.
If there is any problem in actual use, I will add it!!I feel that the b guide has already said it very well
1. If you add an independent attention mechanism layer, it may affect the number of subsequent layers (the number of layers of the feature map layer received from the backbone will change)
2. Generally not added to the backbone extraction network to avoid affecting the pre-training weights
边栏推荐
猜你喜欢
随机推荐
MarkDown语法汇总
redis分布式锁和看门狗的实现
Flask-SQLAlchemy
第十一单元 序列化器
8576 顺序线性表的基本操作
Flask请求应用上下文源码分析
世界上最大的开源基金会 Apache 是如何运作的?
如何解决1045无法登录mysql服务器
How to solve mysql service cannot start 1069
【Tensorflow】AttributeError: module 'keras.backend' has no attribute 'tf'
第二届中国Rust开发者大会(RustChinaConf 2021~2022)线上大会正式开启报名
[ROS] (04) Detailed explanation of package.xml
Raft对比ZAB协议
Flask框架深入二
Chapter6 visualization (don't want to see the version)
Hands-on OCR (1)
Flask框架
jwt(json web token)
ftp常用命令详解_iftop命令详解
[ROS](06)ROS通信 —— 话题(Topic)通信