Refactor classes to inherit from nn.Module instead of nn.Sequential#17493
Merged
amyeroberts merged 6 commits intohuggingface:mainfrom Jun 1, 2022
Merged
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
sgugger
approved these changes
May 31, 2022
Collaborator
sgugger
left a comment
There was a problem hiding this comment.
Thanks a lot for working on this! I don't think we will remove the use of nn.Sequential inside a module so this case should be left as is.
5 tasks
LysandreJik
approved these changes
Jun 1, 2022
Member
LysandreJik
left a comment
There was a problem hiding this comment.
Great, thank you @amyeroberts!
Narsil
pushed a commit
to Narsil/transformers
that referenced
this pull request
Jun 7, 2022
…uggingface#17493) * Adapt Maskformer, VAN, ResNet and RegNet modules to inherit from nn.Module
elusenji
pushed a commit
to elusenji/transformers
that referenced
this pull request
Jun 12, 2022
…uggingface#17493) * Adapt Maskformer, VAN, ResNet and RegNet modules to inherit from nn.Module
amyeroberts
added a commit
to amyeroberts/transformers
that referenced
this pull request
Jun 16, 2022
…uggingface#17493) * Adapt Maskformer, VAN, ResNet and RegNet modules to inherit from nn.Module
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.
What does this PR do?
Refactors classes that inherit from
nn.Sequentialto inherit fromnn.Moduleinstead. This is to make the code easier to debug and inspect.Changes:
forwardmethod implemented for classesadd_module(str_ind, layer)in__init__. This provides backwards compatibility as the submodules will be named according to their position in the call stack, like in nn.Sequential, which is needed to load in the same checkpoints.Note: This does not include other possible
nn.Sequentialrefactoring within modules e.g. lxmert, or inheriting fromModuleListe.g. in Beit. These are more involved changes and should be address in separate PRs.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed.