gpflow¶
gpflow.Module¶
- class gpflow.Module(name=None)[source]¶
Bases:
tensorflow.python.module.module.Module- Attributes
nameReturns the name of this module as passed or determined in the ctor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
- parameters
submodulesSequence of all sub-modules.
- trainable_parameters
trainable_variablesSequence of trainable variables owned by this module and its submodules.
variablesSequence of variables owned by this module and its submodules.
Methods
with_name_scope(method)Decorator to automatically enter the module name scope.
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:
tensorflow_probability.python.util.deferred_tensor.TransformedVariable- Attributes
also_trackAdditional variables tracked by tf.Module in self.trainable_variables.
- bijector
dtypeRepresents the type of the elements in a Tensor.
initializerThe initializer operation for the underlying variable.
nameThe string name of this object.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
pretransformed_inputInput to transform_fn.
- prior_on
shapeRepresents the shape of a Tensor.
submodulesSequence of all sub-modules.
trainableTrue if this instance is trainable, else False.
trainable_variablesSequence of trainable variables owned by this module and its submodules.
- transform
transform_fnFunction which characterizes the `Tensor`ization of this object.
- unconstrained_variable
variablesSequence of variables owned by this module and its submodules.
Methods
assign(value[, use_locking, name, read_value])Assigns constrained value to the unconstrained parameter's variable.
assign_add(delta[, use_locking, name, ...])Adds a value to this variable.
assign_sub(delta[, use_locking, name, ...])Subtracts a value from this variable.
get_shape()Legacy means of getting Tensor shape, for compat with 2.0.0 LinOp.
Log of the prior probability density of the constrained variable.
numpy()Returns (copy of) deferred values as a NumPy array or scalar.
set_shape(shape)Updates the shape of this pretransformed_input.
with_name_scope(method)Decorator to automatically enter the module name scope.
- Parameters
value (
Union[int,float,Sequence[Any],ndarray,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]) –unconstrained_shape (
Optional[Sequence[Optional[int]]]) –constrained_shape (
Optional[Sequence[Optional[int]]]) –shape (
Optional[Sequence[Optional[int]]]) –
- 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,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
- property trainable: bool¶
True if this instance is trainable, else False.
This attribute cannot be set directly. Use
gpflow.set_trainable().- Return type
bool