当前位置:网站首页>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
边栏推荐
猜你喜欢

STM32(F407)—— 堆栈
ROS通信 —— 节点,Nodes & Master](/img/f5/c541259b69a0db3dc15a61e87f0415.png)
[ROS](05)ROS通信 —— 节点,Nodes & Master

Some impressions of the 519 plummet 2021-05-21
CMakeLists.txt详解](/img/34/577c729f06748f625ca0c223496d48.png)
[ROS](03)CMakeLists.txt详解

window10下半自动标注

ZABBIX配置邮件报警和微信报警

【Tensorflow】AttributeError: '_TfDeviceCaptureOp' object has no attribute '_set_device_from_string'

How to solve mysql service cannot start 1069

第十三单元 混入视图基类

yolov5,yolov4,yolov3乱七八糟的
随机推荐
瑞吉外卖笔记——第08讲读写分离
drf视图组件
hsql是什么_MQL语言
MySQL数据库设计规范
关于市场后市的发展预测? 2021-05-23
网页设计(新手入门)[通俗易懂]
The most complete ever!A collection of 47 common terms of "digital transformation", read it in seconds~
2022-08-02日报:2022年7月最热的10篇AI论文
The 2nd China Rust Developers Conference (RustChinaConf 2021~2022) Online Conference Officially Opens Registration
无序数组排序并得到最大间隔
Geoffery Hinton:深度学习的下一个大事件
如何解决1045无法登录mysql服务器
Flask上下文,蓝图和Flask-RESTful
如何解决mysql服务无法启动1069
drf路由组件Routers
paddleocr window10 first experience
redis延时队列
chapter7
第八单元 中间件
第六单元 初识ORM