gpflow

gpflow.Module

class gpflow.Module(*args, **kwargs)[source]

Bases: tensorflow.Module

Attributes
parameters
trainable_parameters

Methods

__call__(self, \*args, \*\*kw)

Call self as a function.

_repr_html_(self) → str[source]

Nice representation of GPflow objects in IPython/Jupyter notebooks

Return type

str

_repr_pretty_(self, p: 'pretty.RepresentationPrinter', cycle: bool) → None[source]

Nice representation of GPflow objects in the IPython shell

Parameters
  • p (RepresentationPrinter) –

  • cycle (bool) –

Return type

None

gpflow.Parameter

class gpflow.Parameter(value, *, transform=None, prior=None, prior_on=<PriorOn.CONSTRAINED: 'constrained'>, trainable=True, dtype=None, name=None)[source]

Bases: tensorflow.Module

Attributes
device
dtype
handle
initial_value
initializer
is_tensor_like

This method means that TensorFlow’s tensor_util.is_tensor function

name
op
prior_on
shape
trainable

True if this instance is trainable, else False.

transform
unconstrained_variable

Methods

__call__(self, \*args, \*\*kw)

Call self as a function.

assign(self, value, float, Sequence[Any], …)

Assigns constrained value to the unconstrained parameter’s variable.

log_prior_density(self)

Log of the prior probability density of the constrained variable.

deref

experimental_ref

get_shape

numpy

read_value

validate_unconstrained_value

value

Parameters
  • value (Union[int, float, Sequence[Any], tensorflow.Tensor, tensorflow.Variable, Parameter]) –

  • transform (Optional[tensorflow_probability.bijectors.Bijector]) –

  • prior (Optional[tensorflow_probability.distributions.Distribution]) –

  • prior_on (Union[str, PriorOn]) –

  • trainable (bool) –

  • dtype (Union[dtype, tensorflow.DType, None]) –

  • name (Optional[str]) –

classmethod _OverloadAllOperators()[source]

Register overloads for all operators.

classmethod _OverloadOperator(operator)[source]

Defer an operator overload to ops.Tensor.

We pull the operator out of ops.Tensor dynamically to avoid ordering issues.

Args:

operator: string. The operator name.

__init__(self, value: Union[int, float, Sequence[Any], tensorflow.Tensor, tensorflow.Variable, ForwardRef('Parameter')], *, transform: Union[tensorflow_probability.bijectors.Bijector, NoneType] = None, prior: Union[tensorflow_probability.distributions.Distribution, NoneType] = None, prior_on: Union[str, gpflow.base.PriorOn] = <PriorOn.CONSTRAINED: 'constrained'>, trainable: bool = True, dtype: Union[numpy.dtype, tensorflow.DType, NoneType] = None, name: Union[str, NoneType] = None)[source]

A parameter retains both constrained and unconstrained representations. If no transform is provided, these two values will be the same. It is often challenging to operate with unconstrained parameters. For example, a variance cannot be negative, therefore we need a positive constraint and it is natural to use constrained values. A prior can be imposed either on the constrained version (default) or on the unconstrained version of the parameter.

Parameters
  • value (Union[int, float, Sequence[Any], tensorflow.Tensor, tensorflow.Variable, Parameter]) –

  • transform (Optional[tensorflow_probability.bijectors.Bijector]) –

  • prior (Optional[tensorflow_probability.distributions.Distribution]) –

  • prior_on (Union[str, PriorOn]) –

  • trainable (bool) –

  • dtype (Union[dtype, tensorflow.DType, None]) –

  • name (Optional[str]) –

assign(self, value: Union[int, float, Sequence[Any], tensorflow.Tensor, tensorflow.Variable, ForwardRef('Parameter')], use_locking: bool = False, name: Union[str, NoneType] = None, read_value: bool = True) → tensorflow.Tensor[source]

Assigns constrained value to the unconstrained parameter’s variable. It passes constrained value through parameter’s transform first.

Example:

``` a = Parameter(2.0, transform=tfp.bijectors.Softplus()) b = Parameter(3.0)

a.assign(4.0) # a parameter to 2.0 value. a.assign(tf.constant(5.0)) # a parameter to 5.0 value. a.assign(b) # a parameter to constrained value of b. ```

Parameters
  • value (Union[int, float, Sequence[Any], tensorflow.Tensor, tensorflow.Variable, Parameter]) – Constrained tensor-like value.

  • use_locking (bool) – If True, use locking during the assignment.

  • name (Optional[str]) – The name of the operation to be created.

  • read_value (bool) – if True, will return something which evaluates to the new value of the variable; if False will return the assign op.

Return type

tensorflow.Tensor

property is_tensor_like

This method means that TensorFlow’s tensor_util.is_tensor function will return True

Return type

bool

log_prior_density(self) → tensorflow.Tensor[source]

Log of the prior probability density of the constrained variable.

Return type

tensorflow.Tensor

property trainable

True if this instance is trainable, else False.

This attribute cannot be set directly. Use gpflow.set_trainable().

Return type

bool

gpflow.default_float

gpflow.default_float()[source]

Returns default float type

gpflow.default_int

gpflow.default_int()[source]

Returns default integer type

gpflow.default_jitter

gpflow.default_jitter()[source]

The jitter is a constant that GPflow adds to the diagonal of matrices to achieve numerical stability of the system when the condition number of the associated matrices is large, and therefore the matrices nearly singular.

gpflow.set_trainable

gpflow.set_trainable(model: Union[tensorflow.Module, Iterable[tensorflow.Module]], flag: bool) → None[source]

Set trainable flag for all tf.Variable`s and `gpflow.Parameter`s in a `tf.Module or collection of `tf.Module`s.

Parameters
  • model (Union[tensorflow.Module, Iterable[tensorflow.Module]]) –

  • flag (bool) –

Return type

None

gpflow.base

gpflow.conditionals

gpflow.config

gpflow.covariances

gpflow.expectations

gpflow.inducing_variables

gpflow.kernels

gpflow.kullback_leiblers

gpflow.likelihoods

gpflow.logdensities

gpflow.mean_functions

Throughout GPflow, by default, latent functions being modelled with Gaussian processes are assumed to have zero mean, f ~ GP(0, k(x,x’)).

In some cases we may wish to model only the deviation from a fixed function with a Gaussian process. For flexibility this fixed function could be both input dependent and parameterised function, μ(x; θ), with some unknown parameters θ, resulting in f ~ GP(μ(x;θ), k(x,x’)).

The GPflow MeanFunction class allows this to be done whilst additionally learning parameters of the parametric function.

gpflow.models

gpflow.monitor

Provides basic functionality to monitor optimisation runs

gpflow.optimizers

gpflow.probability_distributions

gpflow.quadrature

gpflow.utilities