gpflow#
Modules#
- gpflow.base
- gpflow.conditionals
- gpflow.config
- gpflow.covariances
- gpflow.expectations
- gpflow.experimental
- gpflow.functions
- gpflow.inducing_variables
- gpflow.kernels
- gpflow.kullback_leiblers
- gpflow.likelihoods
- gpflow.logdensities
- gpflow.models
- gpflow.monitor
- gpflow.optimizers
- gpflow.posteriors
- gpflow.probability_distributions
- gpflow.quadrature
- gpflow.type_flags
- gpflow.utilities
Classes#
gpflow.Module#
- class gpflow.Module(name=None)[source]#
Bases:
Module
Modules recursively compose other Modules and parameters to create models. Compared to the tf.Module base class, gpflow.Module includes additional support for handling gpflow.Parameter attributes, see
parameters
andtrainable_parameters
. It also adds pretty-printing within IPython and Jupyter notebooks. All GPflow models, kernels, mean functions etc. are Modules. See this guide for an introduction to this class. See also TensorFlow’s documentation for the base class which goes into more detail as to why we use Module objects to compose things.
gpflow.Parameter#
- class gpflow.Parameter(value, *, transform=None, prior=None, prior_on=None, trainable=None, dtype=None, name=None, unconstrained_shape=None, constrained_shape=None, shape=None)[source]#
Bases:
TransformedVariable
A parameter retains both constrained and unconstrained representations. If no transform is provided, these two values will be the same. It is often challenging for humans to operate with unconstrained parameters, although this is typically easier for the optimiser. 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.
See this guide for an introduction to this class.
- Parameters:
unconstrained_shape (
Optional
[Sequence
[Optional
[int
]]]) – Declare the shape of the unconstrained / pre-transformed values. Useful for setting dynamic shapes.constrained_shape (
Optional
[Sequence
[Optional
[int
]]]) – Declare the shape of the constrained / transformed values. Useful for setting dynamic shapes.shape (
Optional
[Sequence
[Optional
[int
]]]) – Convenience shortcut for setting both unconstrained_shape and constrained_shape to the same value.value (
Union
[int
,float
,Sequence
[Any
],ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
]) –transform (
Optional
[Bijector
]) –prior (
Optional
[Distribution
]) –prior_on (
Union
[str
,PriorOn
,None
]) –trainable (
Optional
[bool
]) –dtype (
Union
[dtype
,DType
,None
]) –name (
Optional
[str
]) –
- assign(value, use_locking=False, name=None, read_value=True)[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
],ndarray
[Any
,Any
],Tensor
,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:
Tensor
- log_prior_density()[source]#
Log of the prior probability density of the constrained variable.
- Return type:
Tensor
- Returns:
return has shape [].
- property trainable: bool#
True if this instance is trainable, else False.
This attribute cannot be set directly. Use
gpflow.set_trainable()
.
Functions#
gpflow.default_float#
gpflow.default_int#
gpflow.default_jitter#
gpflow.set_trainable#
- gpflow.set_trainable(model, flag)[source]#
Set trainable flag for all
tf.Variable
s andgpflow.Parameter
s in atf.Module
or collection oftf.Module
s.- Parameters:
model (
Union
[Module
,Iterable
[Module
]]) –flag (
bool
) –
- Return type:
None