-
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
Module Slicing 2 #169
base: master
Are you sure you want to change the base?
Module Slicing 2 #169
Conversation
elegy/slicing.py
Outdated
sample_input: np.ndarray, | ||
) -> elegy.Model: | ||
|
||
model.maybe_initialize(elegy.types.Mode.pred, x=sample_input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you update to master maybe you can check for model.initialized
since maybe_initialize
is gone.
Thanks @alexander-g! I have one main question: are the parameters being transferred to the new module thanks to I am assuming the answer is yes which is fine, however, if this is so, should this method be part of Due to recent changes your example might require some minor modifications:
|
Parameters are transferred but I do not call
Yes, I've added
This is a bit annoying and counterintuitive that I have to initialize a pretrained Model. Can this be avoided? Ready for review. |
Interesting. In the latest version I think you have to be more explicit about this but its just a single line of code.
Ok so there is a pathological case here I'll show next so I coded a "defensive" solution but I am open to suggestions: We conditionally initialize on model.fit(X_train, y_train)
preds = model.predict(X_train) but doing this will raise exceptions on initialization since the losses and metrics don't get the label information because preds = model.predict(X_train)
model.fit(X_train, y_train) So the proposed solution is to have the user opt-in via |
@alexander-g Now that its not a draft I think just commit a random change. |
You're right, it's required, I've added it. It had worked before simply because of the same random seed. |
@alexander-g is this ready for review? :) |
Yes it is. |
Hey @alexander-g! Sorry for the hiatus, a couple of change important changes recently kept me busy, good new is that my new employer is sponsoring a couple of hours a week for me to work on Elegy continuously :) Regarding this PR, I definitely think its best that |
Codecov Report
@@ Coverage Diff @@
## master #169 +/- ##
==========================================
+ Coverage 87.19% 87.85% +0.65%
==========================================
Files 136 138 +2
Lines 7433 7770 +337
==========================================
+ Hits 6481 6826 +345
+ Misses 952 944 -8
Continue to review full report at Codecov.
|
|
Alternative approach to #115
jax.make_jaxpr
andjax.named_call
, not on summaries. Specifically, I've extended hooks context with a new attribute, if it is active,Module.call
will be wrapped withjax.named_call
. This allows identifying individual modules in the low-level jaxpr commands, so the interface is basically the same as before. However, one can now use arbitrary JAX functions without having to wrap them in modules:WIP, still need to cover some edge cases and test more