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

Optimizer serialization #101

Open
coreylowman opened this issue Jul 20, 2022 · 2 comments
Open

Optimizer serialization #101

coreylowman opened this issue Jul 20, 2022 · 2 comments
Labels
new feature New feature or request

Comments

@coreylowman
Copy link
Owner

coreylowman commented Jul 20, 2022

A common feature to use when building training frameworks is to save the optimizer state along with network state.

There's already a way to convert a D::Vec<E> into a rust Vec<E>, which should make it easy to save Gradients object. However a pain point is that gradients are currently keyed off of UniqueId, which may not be persistent across saving/loading depending on how model is initialized.

Options:

  1. Move optimizers away from Gradients and towards using HashMap<String, D::Vec<E>> where String would be the full path to the tensor. This would make it easy to use with TensorCollection, and also require minimal changes to implement this serialization.
  2. The API for serializing optimizers could go through a model, so optimizer gets full paths to tensors on save.
@coreylowman coreylowman changed the title impl SaveToNpz and LoadFromNpz for optimizers optimizer serialization Mar 8, 2023
@coreylowman coreylowman changed the title optimizer serialization Optimizer serialization Mar 8, 2023
@coreylowman coreylowman added the new feature New feature or request label Mar 8, 2023
@kurnevsky
Copy link
Contributor

It's also good to have a way to clone in memory the state of optimizer. It's useful if you want to pit 2 networks to see if the trained network performs better than the one before training (which is part of alpha go algorithm).

@coreylowman
Copy link
Owner Author

@kurnevsky thanks for bringing that up, cloning optimizers is actually really easy with some changes recently. Addressed in the above PR 👍

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

No branches or pull requests

2 participants