secondmind-labs / trieste

A Bayesian optimization toolbox built on TensorFlow
Apache License 2.0
221 stars 42 forks source link

Convert feature-function call inputs to be a tensor to fix pickling #745

Closed khurram-ghani closed 1 year ago

khurram-ghani commented 1 year ago

Fixes pickling issue introduced by #736, causing two integration tests to fail on develop.

It is important that the feature-function is called with a tensor, instead of a parameter (which inducing points can be). This is to ensure pickling works correctly. First time a Keras layer (i.e. feature-functions) is built, the shape of the input is used to set the input-spec. If the input is a parameter, the input-spec will not be for an ordinary tensor and pickling will fail.

Note: the call here was not wrapped in tf.convert_to_tensor, since flat_x should already be a tensor.