mlr3torch icon indicating copy to clipboard operation
mlr3torch copied to clipboard

Deep cloning of Learners

Open sebffischer opened this issue 2 years ago • 2 comments

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)

sebffischer avatar Jan 24 '23 10:01 sebffischer

Note that we need to distinguish between bundled and unbundled models.

sebffischer avatar Jan 25 '24 10:01 sebffischer

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

sebffischer avatar Feb 08 '24 16:02 sebffischer