在GPflow 2.0中设置超参数优化范围 [英] Setting hyperparameter optimization bounds in GPflow 2.0

查看:230
本文介绍了在GPflow 2.0中设置超参数优化范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GPflow 1.0中,如果我想在像lengthscale这样的参数上设置硬边界(即,限制参数的优化范围),

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.)

将参数限制在4到6之间.

would bound the parameter between 4 and 6.

GPflow 2.0的文档说,转换由TensorFlow Probability的Bijector类处理.哪个Bijector类可以处理对参数的硬限制设置,以及实现它的正确方法是什么?

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?

此处提出了类似的问题(内核的超参数;初始化和设置边界).但是由于GPflow 1.0不涉及使用Bijector,所以我提出了一个新问题.

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.

推荐答案

使用双射链很容易做到这一点:

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>

现在,您可以将logistic bijector直接传递给Parameter构造函数.

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>

这篇关于在GPflow 2.0中设置超参数优化范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆