GPflow wrapper update may be incompatible with tf.function()
See original GitHub issueAs mentioned on https://github.com/secondmind-labs/trieste/pull/54, there might be an issue with the current way of how Trieste updates data in GPflow models when you want to use tf.function
to speed up the prediction step (currently, Trieste only uses tf.function
for model optimization, and relies on eager mode for predictions).
VariationalGaussianProcess.update() sets the model’s data
attribute to the new (X, Y) tuple. However, if model.predict_f() is wrapped in tf.function(), it will store the values of (X, Y) when first called in the cached graph.
To enable data update with tf.function(), model.data must be set to a tuple of tf.Variable
s, which are then .assign()ed rather than overwritten in VariationalGaussianProcess.update().
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Why is GPflow's Scipy optimizer incompatible with decorating ...
Scipy() is a wrapper around Scipy's minimize(), and as it calls into non-TensorFlow operations, you cannot wrap it in tf.function .
Read more >GPflow with TensorFlow 2
In TensorFlow 2, we can optimize (trainable) model parameters with TensorFlow optimizers using tf.GradientTape . In this simple example, we perform one gradient ......
Read more >tf.function | TensorFlow v2.11.0
Compiles a function into a callable TensorFlow graph. ... f() <tf.Tensor: ... numpy=array([7, 7], ...)> func may also use ops with side ...
Read more >Bayesian Optimisation for Sequential Experimental Design ...
Finding the optimal design of an experiment can be challenging. ... then the acquisition function will be updated with the results of that...
Read more >GPflow - Bountysource
Currently, the GPflow Scipy optimizer wrapper ( gpflow.optimizers. ... as well as deserialization functions for each submodule (e.g. we would deserialize a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately the
tf.eye
function only supportsTensor
s, PythonIntegral
andnp.integer
types for the first input. If none of those work withtf.function
you could consider creating a subclass of the VGP model in Trieste to turn thenum_data
attribute into a@property
. Then it could be dynamically calculated from the size of the Xdata variable. If that works we could incorporate it into GPflow.I’m currently looking at this (see #271) and am hitting an issue with updating the VGP wrapper. Putting
model.data
in two variables works fine, but puttingmodel.num_data
in a variable causes theelbo
method to fail when it tries to executetf.eye(self.num_data, dtype=default_float())
, claiming theself.num_data
isn’t an integer. Any idea if there’s a way round this? @johnamcleod