当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
drf源码分析与全局捕获异常
logback源码阅读(二)日志打印,自定义appender,encoder,pattern,converter
第十三单元 混入视图基类
【Tensorflow】AttributeError: module ‘keras.backend‘ has no attribute ‘tf‘
EasyExcel 的使用
Flask框架
线代:已知一个特征向量快速求另外两个与之正交的特征向量
如何选择正规的期货交易平台开户?
第十四单元 视图集及路由
瑞吉外卖笔记——第08讲读写分离
Flask上下文,蓝图和Flask-RESTful
深度学习框架pytorch快速开发与实战chapter3
Unit 7 ORM table relationships and operations
[ROS] Compiling packages packages encounters slow progress or stuck, use swap
第十五单元 分页、过滤
如何自定义feign方法级别的超时时间
yolov5,yolov4,yolov3乱七八糟的
yolov5,yolov4,yolov3 mess
The future of financial services will never stop, and the bull market will continue 2021-05-28
MySQL数据库设计规范


![[ROS] (06) ROS Communication - Topic Communication](/img/21/d79f2c4e246eb9ea39df9c7435bb36.png)






