mlr3torch
mlr3torch copied to clipboard
Deep cloning of Learners
It would be nice to be able to create a proper deep clone of a trained torch learner.
- [x] Support to clone
nn_modules()has been already added in torch here - [x] We still need a function to clone the optimizer. But presumably we can simply iterate over the optimizer's state dict and clone the tensors if we encounter them (https://torch.mlverse.org/docs/articles/serialization.html?q=serialization#loading-models-saved-in-python) I created an issue here. Note that we also have to update the parameters that are registered in the optimizer to the new parameters of the cloned network. (addressed here: https://github.com/mlverse/torch/pull/1041/files)
Note that we need to distinguish between bundled and unbundled models.
related PRs:
- https://github.com/mlr-org/mlr3/pull/1003
- https://github.com/mlr-org/mlr3torch/pull/198
- https://github.com/mlverse/torch/pull/1134