-
Notifications
You must be signed in to change notification settings - Fork 32
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
Reference preserving hooks #85
Merged
Merged
Conversation
This file contains 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
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
==========================================
- Coverage 73.42% 70.38% -3.05%
==========================================
Files 77 81 +4
Lines 2751 3761 +1010
==========================================
+ Hits 2020 2647 +627
- Misses 731 1114 +383
Continue to review full report at Codecov.
|
cgarciae
changed the title
[WIP] Refactor: object-oriented
[WIP] Refactor: reference preserving hooks.
Aug 16, 2020
cgarciae
changed the title
[WIP] Refactor: reference preserving hooks.
Reference preserving hooks
Aug 17, 2020
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.
This PR implements Haiku's Module system in such a way that hooks preserve reference information. This fixes the following problems that are currently present:
transform
, which lead to the awkward use ofdefer
.While point 2 was solvable by modifying the parameters and states dictionaries according to each new architecture, there was no clear strategy on how to make this ergnonomic.
Reference preserving hooks use python objects to store references to submodules, parameters and states as is commonly done in Keras and Pytorch, therefore any change in code architecture leads to a change in parameter structure.
Submodule hooks are implemented by leveraging Metaclasses in such a way that all submodules created inside
call
are automatically registered inside the parent module.