Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting hyperparameter optimization bounds in GPflow 2.0

In GPflow 1.0, if I wanted to set hard bounds on a parameter like lengthscale (i.e. limiting the optimisation range for the parameter),

transforms.Logistic(a=4., b=6.)

would bound the parameter between 4 and 6.

GPflow 2.0's documentation says that transforms are handled by TensorFlow Probability's Bijector classes. Which Bijector class handles setting hard limits on parameters, and what is the proper way to implement it?

A similar question was asked here (Kernel's hyper-parameters; initialization and setting bounds) regarding GPflow 1.0. But since GPflow 1.0 did not involve use of Bijectors, I have opened a new question.

like image 210
Rcameron Avatar asked Dec 04 '25 18:12

Rcameron


1 Answers

This is fairly easy to do with the chain of bijectors:

In [35]: a = 3.0
    ...: b = 5.0
    ...: affine = tfp.bijectors.AffineScalar(shift=a, scale=(b - a))
    ...: sigmoid = tfp.bijectors.Sigmoid()
    ...: logistic = tfp.bijectors.Chain([affine, sigmoid])

In [36]: logistic.forward(logistic.inverse(3.1) + 0.0)
Out[36]: <tf.Tensor: id=222, shape=(), dtype=float32, numpy=3.1>

Now, you can pass logistic bijector to the Parameter constructor directly.

In [45]: p = gpflow.Parameter(3.1, transform=logistic, dtype=tf.float32)

In [46]: p
Out[46]: <tf.Tensor: id=307, shape=(), dtype=float32, numpy=3.1>

In [47]: p.unconstrained_variable
Out[47]: <tf.Variable 'Variable:0' shape=() dtype=float32, numpy=-2.9444401>
like image 51
Artem Artemev Avatar answered Dec 06 '25 06:12

Artem Artemev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!