Skip to content
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

activity_regularizer is omitted from get_config/serialization #19820

Closed
sikchi opened this issue Jun 9, 2024 · 3 comments
Closed

activity_regularizer is omitted from get_config/serialization #19820

sikchi opened this issue Jun 9, 2024 · 3 comments
Assignees

Comments

@sikchi
Copy link

sikchi commented Jun 9, 2024

simple to repro:

from keras import layers as kl
from keras import regularizers as kr
kl.Dense(units=16, kernel_regularizer=kr.l2(), activity_regularizer = kr.l2()).get_config().get("activity_regularizer") # evaluates to None
kl.Dense(units=16, kernel_regularizer=kr.l2(), activity_regularizer = kr.l2()).get_config().get("kernel_regularizer") # evaluates to a dict as expected

Noticed this issue when I saw that if you save a model in .keras format and load it again, it is missing activity_regularizer.

Let me know if this is by design/actvity_regularizer is deprecated/etc.

@fchollet
Copy link
Member

fchollet commented Jun 9, 2024

Thanks for the report. This was an oversight. This is now fixed at HEAD.

@fchollet fchollet closed this as completed Jun 9, 2024
@sikchi
Copy link
Author

sikchi commented Jun 10, 2024

Thanks for the super fast fix!

I have a broader question - Based on this - https://keras.io/api/models/model_saving_apis/ I assume I should be able to save a partially trained model using model.save(), then load it using load_model(), and resume training. Note that the document does not explicitly say that.

If my assumption is true, then there are other issues: for e.g., for a trained model with a (non-custom) Loss, model.get_config().get("losses") and model.get_config.get("loss") both return None. Whereas model.losses and model.loss work as expected. Consequently, those properties don't roundtrip via save() and load_model().

LMK if this is by design/alternatives/..

@sikchi
Copy link
Author

sikchi commented Jun 11, 2024

@fchollet @mehtamansi29 : not sure if you saw my previous comment.

LMK if I should open a new issue instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants