geoml.latent

The nodes a model’s latent network is composed from. A network is built bottom-up — an input node, one or more GP nodes above it, operations that combine them — and handed to VGPNetwork as its latent_network.

The signatures here are unannotated on purpose: everything below the constructors is tensor code, where a tf.Tensor in and a tf.Tensor out says nothing about the rank, dtype or axis order that actually goes wrong. The constructors’ own arguments are documented in their docstrings.

Inputs

geoml.latent.network.simulation_rule(qmc)[source]

Chooses how the posterior simulations are drawn while active.

geoml.latent.network.propagation_rule(rule)[source]

Chooses how experts propagate their inducing sets while active.

geoml.latent.network.refresh_cached(network, jitter=1e-06)[source]

Refreshes a network once and snapshots it for prediction.

refresh is pure arithmetic over parameters that do not move during prediction, but running it eagerly pays Python overhead for each of the K x K covariance blocks a multi-expert network builds – at 32 experts that is most of a predict call. Tracing it collapses those into one graph call. The trace is kept on the network, so predicting again does not rebuild it, and it reads the parameters live, so it also follows further training.

Parameters:
  • network – The output node of a latent network.

  • jitter (float) – Small value added to the covariance matrices for numerical stability.

exception geoml.latent.network.NodeIncompatibilityError[source]

Bases: Exception

Exception raised for incompatibilities between a node and its parents/children.

exception geoml.latent.network.BrokenPropagationError[source]

Bases: NodeIncompatibilityError

Exception raised when inducing points can’t be propagated through nodes.

exception geoml.latent.network.SizeIncompatibilityError[source]

Bases: NodeIncompatibilityError

Exception raised for incompatibilities in the number of latent variables in nodes.

class geoml.latent.network.BasicInput(inducing_points, transform=Identity(), fix_transform=False, center=False, name=None)[source]

Bases: _RootLatentVariable

Basic input node.

Converts a deterministic input (usually spatial coordinates) into Gaussian latent variables with zero variance, after applying a transform for normalization. Also defines the inducing points that will be propagated to other nodes.

__init__(inducing_points, transform=Identity(), fix_transform=False, center=False, name=None)[source]

Initializer for BasicInput.

Parameters:
  • inducing_points – A PointData object, or a list of these objects.

  • transform – An object from the transform module for normalization.

  • fix_transform (bool) – Whether to fix the transform parameters to prevent them from changing during training.

  • center (bool) – Whether to center the data, based on the inducing points’ bounding box.

  • name (str) – A name for this node, shown in the printed network and accepted by get_node. Numbered automatically if omitted.

get_root_inducing_points()[source]
refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

kl_divergence()[source]
set_parameter_limits(data)[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

predict_directions(x, dir_x, step=0.001)[source]
class geoml.latent.network.Stack(*latent_variables, name=None)[source]

Bases: _Operation

Latent variable stacking.

Consolidates a list of latent variables into a single object.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.Concatenate(*latent_variables, name=None)[source]

Bases: Stack

Latent variable concatenation.

Consolidates a list of latent variables into a single object. This operation requires all its parent nodes to be able to propagate inducing points.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

class geoml.latent.network.BasicGP(parent, size=1, kernel=Gaussian(), fix_range=False, isotropic=False, range_prior=2.0, name=None)[source]

Bases: _GPNode

Standard Gaussian process node.

In this module, GP nodes are able to work with inputs that may be Gaussian, having an associated variance. This variance is integrated by considering it as a squared range and applying the non-stationary covariance.

__init__(parent, size=1, kernel=Gaussian(), fix_range=False, isotropic=False, range_prior=2.0, name=None)[source]

Initializer for BasicGP.

Parameters:
  • parent – Parent node.

  • size – Number of output latent variables

  • kernel – The kernel to use for the covariance matrices.

  • fix_range (bool) – Whether to force a unit range for all input dimensions.

  • isotropic (bool) – If True, forces the same range for all input dimensions.

  • range_prior (float, optional) – Strength of the Gamma prior that regularizes the ranges, which stay point estimates – the prior’s log-density joins the training objective. It peaks at 1, the natural scale of the whitened space every node works in, falls hard as a range collapses toward zero and gently as it grows. Larger values hold on tighter; None removes it, leaving the ranges to the data alone as in versions before 0.6.5.

  • name (str) – A name for this node, shown in the printed network and accepted by get_node. Numbered automatically if omitted.

covariance_matrix(x, y, var_x=None, var_y=None)[source]
refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

cache_prediction_state()[source]

Snapshot the propagated state into Variables (see _state_var).

Called once per prediction (after refresh) for every node in the network. Subclasses holding additional prediction state extend this.

interpolate(x, x_var=None, n_sim=1, seed=(0, 0))[source]
kl_divergence()[source]
class geoml.latent.network.AdditiveGP(parent, size=1, kernel=Gaussian(), fix_range=False, isotropic=False, range_prior=2.0, name=None)[source]

Bases: BasicGP

Additive GP node.

This node is similar to the BasicGP, with the difference that is covariance matrices are computed separately for each input dimension and then averaged. It makes more sense to use it on high-dimensional non-spatial inputs.

covariance_matrix(x, y, var_x=None, var_y=None)[source]
class geoml.latent.network.Linear(parent, size=1, unit_norm=True, weight_prior=1.0, name=None)[source]

Bases: _FunctionalLatentVariable

Linear node.

This node outputs one or more linear combinations of the inputs. Its role in a network depends on its position. Close to a root node it induces rotation in the coordinates. At the end it induces correlations between the outputs, and in the middle it can serve as an information bottleneck.

__init__(parent, size=1, unit_norm=True, weight_prior=1.0, name=None)[source]

Initializer for Linear.

Parameters:
  • parent – Parent node

  • size – Number of output latent variables.

  • unit_norm (bool) – Whether the weights should form a unit norm vector. If False, the weights are free and regularized by weight_prior.

  • weight_prior (float, optional) – Standard deviation of the zero-mean Gaussian prior on the free weights (unit_norm=False only – the unit norm is constraint enough on its own). The weights stay point estimates; the prior’s log-density joins the training objective, so a weight grows only while the data pays for it, which matters because this is the parameter whose count scales with the network (parent.size times size) and no KL prices it. The standard deviation of 1 matches the whitened scale the network works in. None removes the prior and restores the hard [-1, 1] walls of versions before 0.6.5.

  • name (str) – A name for this node.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.SelectInput(parent, columns, name=None)[source]

Bases: _FunctionalLatentVariable

Variable selection.

Returns the specified columns of the input, discarding the others.

__init__(parent, columns, name=None)[source]

Initializer for SelectInput.

Parameters:
  • parent – Parent node.

  • columns (list) – List of indices to retain.

  • name (str) – A name for this node.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.LinearCombination(*latent_variables, unit_variance=True, per_component=False, weight_concentration=2.0, name=None)[source]

Bases: _Operation

Linear combination.

This node combines the inputs linearly with positive weights.

__init__(*latent_variables, unit_variance=True, per_component=False, weight_concentration=2.0, name=None)[source]

Initializer for LinearCombination.

Parameters:
  • latent_variables – Nodes to combine. They must all have the same number of variables.

  • unit_variance (bool) – If True, constrains the weights to unit sum to control the variance of the output.

  • per_component (bool) – One set of mixing weights per output component instead of one for the whole node, so each component takes its own share of each parent – one element can lean on a trend that another ignores. Requires unit_variance, and multiplies the weight count by size, which is why the prior below comes with it.

  • weight_concentration (float, optional) – Concentration of the symmetric Dirichlet prior on each component’s weights (per_component=True only – the shared weights are few enough to need none). The weights stay point estimates; the prior’s log-density joins the training objective, holding each component’s shares near equal until its data argues otherwise. Must exceed 1 for the pull to point at equal shares; None removes it.

  • name (str) – A name for this node.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

predict_directions(x, dir_x, jitter=1e-06)[source]
propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

kl_divergence()[source]
class geoml.latent.network.ProductOfExperts(*latent_variables, name=None)[source]

Bases: _Operation

Product of Experts.

The Product of Experts combines latent variables from different nodes with weights inversely proportional to the local variance. It is more useful when combining the outputs of smaller networks with different set of inducing points, allowing each one to focus on a region of space.

This node treats its parents independently. Means and variances will be “stiched” smoothly, but individual simulations may exhibit artifacts.

This node is not capable of propagating inducing points.

__init__(*latent_variables, name=None)[source]

Initializer for ProductOfExperts.

Parameters:
  • latent_variables – Parent nodes to combine.

  • name (str) – A name for this node.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

predict_directions(x, dir_x, step=0.001)[source]
kl_divergence()[source]
class geoml.latent.network.Exponentiation(parent, name=None)[source]

Bases: _FunctionalLatentVariable

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.Multiply(*latent_variables, name=None)[source]

Bases: _Operation

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

kl_divergence()[source]
class geoml.latent.network.Add(*latent_variables, name=None)[source]

Bases: _Operation

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

kl_divergence()[source]
class geoml.latent.network.Bias(parent, scale=5, name=None)[source]

Bases: _FunctionalLatentVariable

Adds a deterministic constant to its input.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.Scale(parent, name=None)[source]

Bases: _FunctionalLatentVariable

Scale.

Multiplies its input by a constant. The variance is multiplied by the square of the same value.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

predict_directions(x, dir_x, step=0.001)[source]
class geoml.latent.network.RadialTrend(parent, size=1, name=None)[source]

Bases: _FunctionalLatentVariable

Radial trend.

This node outputs a (hyper)spherical deterministic function, positive on the inside and negative on the outside. It can be made ellipsoidal or with a more complex shape depending on its parent nodes. Its main use is for implicit geological modelling.

It will ignore the variance of its inputs.

__init__(parent, size=1, name=None)[source]

Initializer for RadialTrend.

Parameters:
  • parent – Parent node.

  • size (int) – Number of output functions to generate.

  • name (str) – A name for this node.

compute_trend(x)[source]
compute_trend_gradient(x)[source]
refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

predict_directions(x, dir_x, step=0.001)[source]
class geoml.latent.network.GPWalk(parent, step=0.01, n_steps=10, name=None)[source]

Bases: _FunctionalLatentVariable

Stochastic Differential Equation.

This node uses the vector field defined by its parent to move points in space. After each step the field is reevaluated and the point’s mean, variance, and direction is updated. It is very effective to learn non-stationary patterns, but it is computationally expensive.

The node’s parent (a GP) defines the vector field and the parent’s parent contains the coordinates that will be moved. Both must have the same size.

__init__(parent, step=0.01, n_steps=10, name=None)[source]

Initializer for GPWalk.

In principle the step argument does not need to be changed, as the underlying GP tends to adjust its amplitude to take larger or smaller steps in practice. A higher n_steps allows the model to have finer control of the points’ trajectories at a higher computational cost. n_steps=5 seems to be the minimum possible for practical purposes.

Parameters:
  • parent – Parent node. Must be a GP variant.

  • step (float) – Size of the step at each iteration.

  • n_steps (int) – Number of steps.

  • name (str) – A name for this node.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
compute_path(x, x_var=None)[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.MultiStructureGP(parent, size=1, kernel=Gaussian(), fix_range=False, n_structures=2, weight_concentration='staircase', range_prior=2.0, name=None)[source]

Bases: BasicGP

Gaussian process with multiple structures.

A linear combination of multiple kernels with (possibly) different ranges. The difference between using this node and applying a linear combination externally is that here the combination is at the kernel level instead of the latent variable level.

__init__(parent, size=1, kernel=Gaussian(), fix_range=False, n_structures=2, weight_concentration='staircase', range_prior=2.0, name=None)[source]

Initializer for MultiStructureGP.

Parameters:
  • parent – Parent node.

  • size (int) – Number of output functions.

  • kernel – The kernel to use for the covariance matrices.

  • fix_range (bool) – Whether to force a unit range for all input dimensions.

  • n_structures (int) – Number of kernels to combine (minimum 2).

  • weight_concentration (str, float, or None) – The Dirichlet prior on the structure weights, which stay point estimates – the prior’s log-density joins the training objective. “staircase” (the default) aligns the prior with the ranges: structure n starts with range 1 / (n + 1), and its weight’s share of the prior’s peak follows the same ordering, so mass sits on the long-range structure until the data moves it to the short ones. The weights themselves still start uniform – initializing them on the staircase was measured and rejected, since training never left that basin. A number gives a symmetric Dirichlet peaking at equal shares (it must exceed 1); None removes the prior, as in versions before 0.6.5.

  • range_prior (float, optional) – Strength of the Gamma priors on the ranges, one per structure, each peaking at that structure’s own starting range rather than at a common value – a shared peak would fight the staircase the structures exist for. None removes them.

  • name (str) – A name for this node.

covariance_matrix(x, y, var_x=None, var_y=None)[source]
class geoml.latent.network.GradientConstrainedInput(inducing_points, directional_data, covariance, size=1, fix_covariance=False, name=None)[source]

Bases: _RootLatentVariable

Inputs constrained by structural data.

This node uses a set of directional data to constrain the output’s gradient. The output GP is considered to have zero gradient in the specified directions, flowing only in the orthogonal direction.

__init__(inducing_points, directional_data, covariance, size=1, fix_covariance=False, name=None)[source]

Initializer for GradientConstrainedInput.

The locations of the provided directional_data will be added to the inducing points set to better constrain the output.

Parameters:
  • inducing_points – A PointData object, or a list of these objects.

  • directional_data – A DirectionalData object, or a list of these objects.

  • covariance – A covariance object, containing a kernel and transform.

  • size (int) – Number of output variables.

  • fix_covariance (bool) – Whether to fix the covariance’s parameters during training.

  • name (str) – A name for this node.

get_root_inducing_points()[source]
refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

cache_prediction_state()[source]

Snapshot the propagated state into Variables (see _state_var).

Called once per prediction (after refresh) for every node in the network. Subclasses holding additional prediction state extend this.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

kl_divergence()[source]
set_parameter_limits(data)[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

Gaussian process nodes

class geoml.latent.network.BasicGP(parent, size=1, kernel=Gaussian(), fix_range=False, isotropic=False, range_prior=2.0, name=None)[source]

Bases: _GPNode

Standard Gaussian process node.

In this module, GP nodes are able to work with inputs that may be Gaussian, having an associated variance. This variance is integrated by considering it as a squared range and applying the non-stationary covariance.

__init__(parent, size=1, kernel=Gaussian(), fix_range=False, isotropic=False, range_prior=2.0, name=None)[source]

Initializer for BasicGP.

Parameters:
  • parent – Parent node.

  • size – Number of output latent variables

  • kernel – The kernel to use for the covariance matrices.

  • fix_range (bool) – Whether to force a unit range for all input dimensions.

  • isotropic (bool) – If True, forces the same range for all input dimensions.

  • range_prior (float, optional) – Strength of the Gamma prior that regularizes the ranges, which stay point estimates – the prior’s log-density joins the training objective. It peaks at 1, the natural scale of the whitened space every node works in, falls hard as a range collapses toward zero and gently as it grows. Larger values hold on tighter; None removes it, leaving the ranges to the data alone as in versions before 0.6.5.

  • name (str) – A name for this node, shown in the printed network and accepted by get_node. Numbered automatically if omitted.

covariance_matrix(x, y, var_x=None, var_y=None)[source]
refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

cache_prediction_state()[source]

Snapshot the propagated state into Variables (see _state_var).

Called once per prediction (after refresh) for every node in the network. Subclasses holding additional prediction state extend this.

interpolate(x, x_var=None, n_sim=1, seed=(0, 0))[source]
kl_divergence()[source]
class geoml.latent.network.AdditiveGP(parent, size=1, kernel=Gaussian(), fix_range=False, isotropic=False, range_prior=2.0, name=None)[source]

Bases: BasicGP

Additive GP node.

This node is similar to the BasicGP, with the difference that is covariance matrices are computed separately for each input dimension and then averaged. It makes more sense to use it on high-dimensional non-spatial inputs.

covariance_matrix(x, y, var_x=None, var_y=None)[source]
class geoml.latent.network.MultiStructureGP(parent, size=1, kernel=Gaussian(), fix_range=False, n_structures=2, weight_concentration='staircase', range_prior=2.0, name=None)[source]

Bases: BasicGP

Gaussian process with multiple structures.

A linear combination of multiple kernels with (possibly) different ranges. The difference between using this node and applying a linear combination externally is that here the combination is at the kernel level instead of the latent variable level.

__init__(parent, size=1, kernel=Gaussian(), fix_range=False, n_structures=2, weight_concentration='staircase', range_prior=2.0, name=None)[source]

Initializer for MultiStructureGP.

Parameters:
  • parent – Parent node.

  • size (int) – Number of output functions.

  • kernel – The kernel to use for the covariance matrices.

  • fix_range (bool) – Whether to force a unit range for all input dimensions.

  • n_structures (int) – Number of kernels to combine (minimum 2).

  • weight_concentration (str, float, or None) – The Dirichlet prior on the structure weights, which stay point estimates – the prior’s log-density joins the training objective. “staircase” (the default) aligns the prior with the ranges: structure n starts with range 1 / (n + 1), and its weight’s share of the prior’s peak follows the same ordering, so mass sits on the long-range structure until the data moves it to the short ones. The weights themselves still start uniform – initializing them on the staircase was measured and rejected, since training never left that basin. A number gives a symmetric Dirichlet peaking at equal shares (it must exceed 1); None removes the prior, as in versions before 0.6.5.

  • range_prior (float, optional) – Strength of the Gamma priors on the ranges, one per structure, each peaking at that structure’s own starting range rather than at a common value – a shared peak would fight the staircase the structures exist for. None removes them.

  • name (str) – A name for this node.

covariance_matrix(x, y, var_x=None, var_y=None)[source]

Combining and reshaping

class geoml.latent.network.Add(*latent_variables, name=None)[source]

Bases: _Operation

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

kl_divergence()[source]
class geoml.latent.network.Multiply(*latent_variables, name=None)[source]

Bases: _Operation

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

kl_divergence()[source]
class geoml.latent.network.LinearCombination(*latent_variables, unit_variance=True, per_component=False, weight_concentration=2.0, name=None)[source]

Bases: _Operation

Linear combination.

This node combines the inputs linearly with positive weights.

__init__(*latent_variables, unit_variance=True, per_component=False, weight_concentration=2.0, name=None)[source]

Initializer for LinearCombination.

Parameters:
  • latent_variables – Nodes to combine. They must all have the same number of variables.

  • unit_variance (bool) – If True, constrains the weights to unit sum to control the variance of the output.

  • per_component (bool) – One set of mixing weights per output component instead of one for the whole node, so each component takes its own share of each parent – one element can lean on a trend that another ignores. Requires unit_variance, and multiplies the weight count by size, which is why the prior below comes with it.

  • weight_concentration (float, optional) – Concentration of the symmetric Dirichlet prior on each component’s weights (per_component=True only – the shared weights are few enough to need none). The weights stay point estimates; the prior’s log-density joins the training objective, holding each component’s shares near equal until its data argues otherwise. Must exceed 1 for the pull to point at equal shares; None removes it.

  • name (str) – A name for this node.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

predict_directions(x, dir_x, jitter=1e-06)[source]
propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

kl_divergence()[source]
class geoml.latent.network.Linear(parent, size=1, unit_norm=True, weight_prior=1.0, name=None)[source]

Bases: _FunctionalLatentVariable

Linear node.

This node outputs one or more linear combinations of the inputs. Its role in a network depends on its position. Close to a root node it induces rotation in the coordinates. At the end it induces correlations between the outputs, and in the middle it can serve as an information bottleneck.

__init__(parent, size=1, unit_norm=True, weight_prior=1.0, name=None)[source]

Initializer for Linear.

Parameters:
  • parent – Parent node

  • size – Number of output latent variables.

  • unit_norm (bool) – Whether the weights should form a unit norm vector. If False, the weights are free and regularized by weight_prior.

  • weight_prior (float, optional) – Standard deviation of the zero-mean Gaussian prior on the free weights (unit_norm=False only – the unit norm is constraint enough on its own). The weights stay point estimates; the prior’s log-density joins the training objective, so a weight grows only while the data pays for it, which matters because this is the parameter whose count scales with the network (parent.size times size) and no KL prices it. The standard deviation of 1 matches the whitened scale the network works in. None removes the prior and restores the hard [-1, 1] walls of versions before 0.6.5.

  • name (str) – A name for this node.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.ProductOfExperts(*latent_variables, name=None)[source]

Bases: _Operation

Product of Experts.

The Product of Experts combines latent variables from different nodes with weights inversely proportional to the local variance. It is more useful when combining the outputs of smaller networks with different set of inducing points, allowing each one to focus on a region of space.

This node treats its parents independently. Means and variances will be “stiched” smoothly, but individual simulations may exhibit artifacts.

This node is not capable of propagating inducing points.

__init__(*latent_variables, name=None)[source]

Initializer for ProductOfExperts.

Parameters:
  • latent_variables – Parent nodes to combine.

  • name (str) – A name for this node.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

predict_directions(x, dir_x, step=0.001)[source]
kl_divergence()[source]
class geoml.latent.network.Stack(*latent_variables, name=None)[source]

Bases: _Operation

Latent variable stacking.

Consolidates a list of latent variables into a single object.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.Concatenate(*latent_variables, name=None)[source]

Bases: Stack

Latent variable concatenation.

Consolidates a list of latent variables into a single object. This operation requires all its parent nodes to be able to propagate inducing points.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

class geoml.latent.network.SelectInput(parent, columns, name=None)[source]

Bases: _FunctionalLatentVariable

Variable selection.

Returns the specified columns of the input, discarding the others.

__init__(parent, columns, name=None)[source]

Initializer for SelectInput.

Parameters:
  • parent – Parent node.

  • columns (list) – List of indices to retain.

  • name (str) – A name for this node.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

Shaping a field

class geoml.latent.network.Bias(parent, scale=5, name=None)[source]

Bases: _FunctionalLatentVariable

Adds a deterministic constant to its input.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.Scale(parent, name=None)[source]

Bases: _FunctionalLatentVariable

Scale.

Multiplies its input by a constant. The variance is multiplied by the square of the same value.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

predict_directions(x, dir_x, step=0.001)[source]
class geoml.latent.network.Exponentiation(parent, name=None)[source]

Bases: _FunctionalLatentVariable

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

class geoml.latent.network.RadialTrend(parent, size=1, name=None)[source]

Bases: _FunctionalLatentVariable

Radial trend.

This node outputs a (hyper)spherical deterministic function, positive on the inside and negative on the outside. It can be made ellipsoidal or with a more complex shape depending on its parent nodes. Its main use is for implicit geological modelling.

It will ignore the variance of its inputs.

__init__(parent, size=1, name=None)[source]

Initializer for RadialTrend.

Parameters:
  • parent – Parent node.

  • size (int) – Number of output functions to generate.

  • name (str) – A name for this node.

compute_trend(x)[source]
compute_trend_gradient(x)[source]
refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

predict_directions(x, dir_x, step=0.001)[source]
class geoml.latent.network.GPWalk(parent, step=0.01, n_steps=10, name=None)[source]

Bases: _FunctionalLatentVariable

Stochastic Differential Equation.

This node uses the vector field defined by its parent to move points in space. After each step the field is reevaluated and the point’s mean, variance, and direction is updated. It is very effective to learn non-stationary patterns, but it is computationally expensive.

The node’s parent (a GP) defines the vector field and the parent’s parent contains the coordinates that will be moved. Both must have the same size.

__init__(parent, step=0.01, n_steps=10, name=None)[source]

Initializer for GPWalk.

In principle the step argument does not need to be changed, as the underlying GP tends to adjust its amplitude to take larger or smaller steps in practice. A higher n_steps allows the model to have finer control of the points’ trajectories at a higher computational cost. n_steps=5 seems to be the minimum possible for practical purposes.

Parameters:
  • parent – Parent node. Must be a GP variant.

  • step (float) – Size of the step at each iteration.

  • n_steps (int) – Number of steps.

  • name (str) – A name for this node.

propagate(x, x_var=None)[source]

Propagates mean and variance to the next node.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

refresh(jitter=1e-06)[source]

Updates the model’s internal state.

If called within TensorFlow’s eager mode, will allow inspection of the internal tensors.

Parameters:

jitter (float) – Small value added to the covariance matrices for numerical stability.

kl_divergence()[source]
compute_path(x, x_var=None)[source]
predict(x, x_var=None, n_sim=1, seed=(0, 0))[source]

Prediction on the previous node’s latent variables. If n_sim=0 only the mean and variance are returned.

Parameters:
  • x (Tensor) – Mean of the input.

  • x_var (Tensor) – Variance of the input.

  • n_sim (int) – Number of simulations to draw.

  • seed (tuple) – A set of two seeds for the random number generator.

Returns:

  • mu – Mean of the output.

  • var – Variance of the output.

  • sims – A set of simulations generated from the predictive distribution.

  • explained_var – Amount of variance “explained away” by conditioning on the inducing points.

  • influence – Fraction of the full variance that the model is able to sustain at a given position. Increases closer to the inducing points.

When nodes do not fit together

exception geoml.latent.network.NodeIncompatibilityError[source]

Bases: Exception

Exception raised for incompatibilities between a node and its parents/children.

exception geoml.latent.network.BrokenPropagationError[source]

Bases: NodeIncompatibilityError

Exception raised when inducing points can’t be propagated through nodes.

exception geoml.latent.network.SizeIncompatibilityError[source]

Bases: NodeIncompatibilityError

Exception raised for incompatibilities in the number of latent variables in nodes.