5

We've trained a model and want to use it in a few different methods, each of which mutates it. However, the first method call will pollute the model for the subsequent calls.

Ideally we'd like to just deepcopy the model and then pass copies into the mutating methods.

Is this possible? Or is there a better alternative?

2 Answers2

5

Of course. GPflow 2.0.0-rc1 has an implementation of the deep copy, but it is called deepcopy_components

joel
  • 6,359
  • 2
  • 30
  • 55
Artem Artemev
  • 516
  • 3
  • 8
0

Artem's answer applies to the rc1 release candidate of GPflow 2.0. In the final 2.0 release, the function is gpflow.utilities.deepcopy.

You can also take an immutable* snapshot of the model with gpflow.utilities.freeze, which returns the model with each tf.Variable and gpflow.Parameter replaced by a tf.Tensor.

*immutable in that it can't be trained

joel
  • 6,359
  • 2
  • 30
  • 55