-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Bug fix for drop path decay rate in swin transformer #34291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ArthurZucker
merged 19 commits into
huggingface:main
from
abhi-glitchhg:swin_drop_path_bug
Oct 29, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
844999c
potential bug fix for drop path
abhi-glitchhg 2414fe0
variable name change
abhi-glitchhg 10d5dc1
forgot to rename the variables
abhi-glitchhg ee397b6
back to original
deo-abhijit 70624b2
modify dpr properly
deo-abhijit 7ed9071
check_copies auto fix
abhi-glitchhg 9e3a37c
corresponsing swin2 changes
abhi-glitchhg be53da6
auto fix
abhi-glitchhg 1214d4b
linting
abhi-glitchhg 97dd9de
default value for drop_path_rate as 0.0
abhi-glitchhg a8189db
Merge branch 'main' into swin_drop_path_bug
abhi-glitchhg 88122d6
Merge branch 'main' into swin_drop_path_bug
abhi-glitchhg e593c22
Update src/transformers/models/glm/modeling_glm.py
abhi-glitchhg b4ddfc5
maskformer fix
abhi-glitchhg 7504ab0
Merge branch 'swin_drop_path_bug' of https://github.com/abhi-glitchhg…
abhi-glitchhg 67a60fd
ruff format
abhi-glitchhg 1a8e567
changes made to tf code as well
abhi-glitchhg 79f3fcd
lint
abhi-glitchhg 312954d
Merge branch 'main' into swin_drop_path_bug
abhi-glitchhg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -742,7 +742,14 @@ def build(self, input_shape=None): | |
|
|
||
| class TFSwinLayer(keras.layers.Layer): | ||
| def __init__( | ||
| self, config, dim, input_resolution: Tuple[int, int], num_heads: int, shift_size: int = 0, **kwargs | ||
| self, | ||
| config, | ||
| dim, | ||
| input_resolution: Tuple[int, int], | ||
| num_heads: int, | ||
| drop_path_rate: float = 0.0, | ||
| shift_size: int = 0, | ||
| **kwargs, | ||
| ) -> None: | ||
| super().__init__(**kwargs) | ||
| self.chunk_size_feed_forward = config.chunk_size_feed_forward | ||
|
|
@@ -754,8 +761,8 @@ def __init__( | |
| self.layernorm_before = keras.layers.LayerNormalization(epsilon=config.layer_norm_eps, name="layernorm_before") | ||
| self.attention = TFSwinAttention(config, dim, num_heads, name="attention") | ||
| self.drop_path = ( | ||
| TFSwinDropPath(config.drop_path_rate, name="drop_path") | ||
| if config.drop_path_rate > 0.0 | ||
| TFSwinDropPath(drop_path_rate, name="drop_path") | ||
| if drop_path_rate > 0.0 | ||
| else keras.layers.Activation("linear", name="drop_path") | ||
| ) | ||
| self.layernorm_after = keras.layers.LayerNormalization(epsilon=config.layer_norm_eps, name="layernorm_after") | ||
|
|
@@ -913,6 +920,7 @@ def __init__( | |
| input_resolution=input_resolution, | ||
| num_heads=num_heads, | ||
| shift_size=0 if (i % 2 == 0) else config.window_size // 2, | ||
| drop_path_rate=drop_path[i], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice fix - and aligned with hiera & focalnet which also have a varying drop_path per layer iirc |
||
| name=f"blocks.{i}", | ||
| ) | ||
| for i in range(depth) | ||
|
|
||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.