question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

History and Config in Keras repositories

See original GitHub issue

This is a feature request and discussion between @ariG23498 and me 😂 Wanted to carry this here for opinions.

Aritra thinks it would be cool to have history in repository directly, currently we only write model.history.history in model card. Also if the config dictionary is not provided by the user, we can load the config with get_config (see here for more reference) and host it on the repository. If user provides config as argument, it can be overridden (which I think is not used that much atm).

From what I see in API reference of Keras, this makes models more lightweight and reduces serialization time, so

  1. User setting save_traces = False yet saving config in the repository
  2. Loading config and passing it in custom objects for loading the model should suffice and would be a nice option for users. (correct me if I’m wrong, @ariG23498)

These are both super nice to have, I’ll be releasing my blog without these and later add them. One consideration is we don’t want to add any argument because mixin takes **model_save_kwargs or deprecate config, allow user to override instead. Pinging @nateraw and @gante because I want to know what they think (it’s optional, feel free to pass 🤗) Also, Aritra accepted to co-author this PR with me which I’m super happy of 🥺

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
naterawcommented, May 5, 2022

So IIRC when we made the original implementation, we intentionally avoided loading config this way because it seemed quite complicated. 😅 I definitely think you’re right in that we could do something a bit better.

Right now, you just get the model.config attribute added to your model instance if config is found:

https://github.com/huggingface/huggingface_hub/blob/7042df38a9839ac41efd60cf7f985d473c49d426/src/huggingface_hub/keras_mixin.py#L525

How are we going to validate that the config that’s found is going to be valid for something like from_config for a given model? Couldn’t this potentially start breaking previously uploaded models somehow? (sorry if I’m missing something here 😅)

Also, if folks already aren’t really using:

  1. The custom model feature too much
  2. The config when it comes to Keras,

Do we expect users to use it for get_config/from_config in custom models?


As for history, which is a separate issue, I think that sounds great to include it as some dictionary file history.json. 🤗

2reactions
ariG23498commented, Apr 19, 2022

On top of what @merveenoyan documented brilliantly I also think we should compare the the pytorch auto-filling of cards with that of Keras. If we can align the expectation it would be a more controlled effort in building this API better.

WDYT?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Display Deep Learning Model Training History in Keras
Visualize Model Training History in Keras ... You can create plots from the collected history data. In the example below, a small network...
Read more >
History of keras fit() in when fitting multiple times
Show activity on this post. The question was whether it is possible to fit() a keras model multiple times (e.g. due to a...
Read more >
Keras callbacks and config files | Kaggle
These callbacks can be passed to a model during fit time. They allow us to modify the classifier as it is run, or...
Read more >
Keras Applications
Model Size (MB) Top‑1 Accuracy Top‑5 Accuracy Parameters Depth Time (ms) per infer... Xception 88 79.0% 94.5% 22.9M 81 109.4 VGG16 528 71.3% 90.1% 138.4M...
Read more >
Why reset model.history? / comprehensive model state saving
"individual chunks" of history could be easily concatenated outside keras, if needed. built-in callbacks could be ignored, and only used as an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found