[Feature] Add attention module of CBAM#246
Merged
Merged
Conversation
Added tutorials on the use of the attention module
Nioolek
reviewed
Nov 5, 2022
Collaborator
|
Pls fix the lint |
hhaAndroid
reviewed
Nov 7, 2022
hhaAndroid
reviewed
Nov 8, 2022
hhaAndroid
reviewed
Nov 8, 2022
| super(ChannelAttention, self).__init__() | ||
| self.avg_pool = nn.AdaptiveAvgPool2d(1) | ||
| self.max_pool = nn.AdaptiveMaxPool2d(1) | ||
| self.conv1 = ConvModule( |
hhaAndroid
reviewed
Nov 8, 2022
Nioolek
reviewed
Nov 8, 2022
| def __init__(self, | ||
| channels: int, | ||
| ratio: int = 16, | ||
| act_cfg: Union[int, Sequence[int]] = (dict(type='ReLU'), |
Collaborator
There was a problem hiding this comment.
Union[int, Sequence[int]]?
Nioolek
reviewed
Nov 8, 2022
| conv_cfg=None, | ||
| act_cfg=None) | ||
|
|
||
| self.activate1 = MODELS.build(act_cfg[0]) |
PeterH0323
reviewed
Nov 9, 2022
| CBAM( | ||
| in_channels=16, | ||
| act_cfg=dict( | ||
| ChannelAttention=(dict(type='ReLU'), ), |
Collaborator
There was a problem hiding this comment.
Suggested change
| ChannelAttention=(dict(type='ReLU'), ), | |
| ChannelAttention=(dict(type='ReLU')), |
Comment on lines
+19
to
+20
| stages=(False, False, True, True)), | ||
| ], )) |
Collaborator
There was a problem hiding this comment.
Suggested change
| stages=(False, False, True, True)), | |
| ], )) | |
| stages=(False, False, True, True)) | |
| ])) |
hhaAndroid
reviewed
Nov 9, 2022
| def __init__(self, | ||
| channels: int, | ||
| ratio: int = 16, | ||
| act_cfg: Union[dict, |
RangeKing
reviewed
Nov 9, 2022
hhaAndroid
reviewed
Nov 10, 2022
|
|
||
|
|
||
| class ChannelAttention(BaseModule): | ||
| """ChannelAttention |
Member
There was a problem hiding this comment.
Suggested change
| """ChannelAttention | |
| """ChannelAttention | |
|
|
||
|
|
||
| class SpatialAttention(BaseModule): | ||
| """SpatialAttention |
Member
There was a problem hiding this comment.
Suggested change
| """SpatialAttention | |
| """SpatialAttention | |
hhaAndroid
approved these changes
Nov 10, 2022
hhaAndroid
pushed a commit
that referenced
this pull request
Nov 10, 2022
* Add Attention Modules * Adde tutorials on the use of the attention module in How_to * Update how_to.md Added tutorials on the use of the attention module * Update attention_layers.py * Rename attention_layers.py to cbam_layer.py * Update __init__.py * Update how_to.md * Update how_to.md * Update how_to.md * Update cbam_layer.py * Update cbam_layer.py * Update cbam_layer.py * Update how_to.md * update * add docstring typehint * add unit test * refine unit test * updata how_to * add plugins directory * refine plugin.md * refine cbam.py and plugins.md * refine cbam.py and plugins.md * fix error in test_cbam.py * refine cbam.py and fix error in test_cbam.py * refine cbam.py and plugins.md * refine cbam.py and docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
Add attention module of CBAM
Modification