AutonomousExperimenterFvGP

class gpcam.autonomous_experimenter.AutonomousExperimenterFvGP(input_space_bounds, output_number, output_dim=1, hyperparameters=None, hyperparameter_bounds=None, instrument_function=None, init_dataset_size=None, acquisition_function='variance', cost_function=None, cost_update_function=None, cost_function_parameters=None, kernel_function=None, prior_mean_function=None, noise_function=None, run_every_iteration=None, x_data=None, y_data=None, noise_variances=None, vp=None, dataset=None, communicate_full_dataset=False, compute_device='cpu', store_inv=False, training_dask_client=None, acq_func_opt_dask_client=None, gp2Scale=False, gp2Scale_dask_client=None, gp2Scale_batch_size=10000, ram_economy=True, info=False, args=None)

Executes the autonomous loop for a multi-task Gaussian process.

Parameters:
  • input_space_bounds (np.ndarray) – A numpy array of floats of shape D x 2 describing the input space range

  • output_number (int) – An integer defining how many outputs are created by each measurement.

  • output_dim (int) – Integer specifying the number of dimensions of the output space. Most often 1. This is not the number of outputs/tasks. For instance, a spectrum as output at each input is itself a function over a 1d space but has many outputs.

  • hyperparameters (np.ndarray, optional) – Vector of hyperparameters used by the GP initially. This class provides methods to train hyperparameters. The default is a random draw from a uniform distribution within hyperparameter_bounds, with a shape appropriate for the default kernel (D + 1), which is an anisotropic Matern kernel with automatic relevance determination (ARD). If gp2Scale is enabled, the default kernel changes to the anisotropic Wendland kernel.

  • hyperparameter_bounds (np.ndarray, optional) – A 2d numpy array of shape (N x 2), where N is the number of needed hyperparameters. The default is None, in which case the hyperparameter_bounds are estimated from the domain size and the initial y_data. If the data changes significantly, the hyperparameters and the bounds should be changed/retrained. Initial hyperparameters and bounds can also be set in the train calls. The default only works for the default kernels.

  • instrument_function (Callable, optional) – A function that takes data points (a list of dicts), and returns the same with the measurement data filled in. The function is expected to communicate with the instrument and perform measurements, populating fields of the data input.

  • init_dataset_size (int, optional) – If x and y are not provided and dataset is not provided, init_dataset_size must be provided. An initial dataset is constructed randomly with this length. The instrument_function is immediately called to measure values at these initial points.

  • acquisition_function (Callable, optional) – The acquisition function accepts as input a numpy array of size V x D (such that V is the number of input points, and D is the parameter space dimensionality) and a GPOptimizer object. The return value is 1d array of length V providing ‘scores’ for each position, such that the highest scored point will be measured next. Built-in functions can be used by one of the following keys: variance, relative information entropy, relative information entropy set, total correlation. See GPOptimizer.ask() for a short explanation of these functions. In the multi-task case, it is highly recommended to deploy a user-defined acquisition function due to the intricate relationship of posterior distributions at different points in the output space. If None, the default function variance, meaning fvgp.GP.posterior_covariance with variance_only = True will be used. The acquisition function can be a callable of the form my_func(x,gpcam.GPOptimizer) which will be maximized (!!!), so make sure desirable new measurement points will be located at maxima.

  • cost_function (Callable, optional) – A function encoding the cost of motion through the input space and the cost of a measurements. Its inputs are an origin (np.ndarray of size V x D), x (np.ndarray of size V x D), and the value of cost_function_parameters; origin is the starting position, and x is the destination position. The return value is a 1d array of length V describing the costs as floats. The ‘score’ from acquisition_function is divided by this returned cost to determine the next measurement point. If None, the default is a uniform cost of 1.

  • cost_update_function (Callable, optional) – A function that updates the cost_func_params which are communicated to the cost_function. This function accepts as input costs (a list of cost values determined by instrument_function), bounds (a V x 2 numpy array) and a parameters object. The default is a no-op.

  • cost_function_parameters (Any, optional) – An object that is communicated to the cost_function and cost_update_function. The default is {}.

  • kernel_function (Callable, optional) – A symmetric positive semi-definite covariance function (a kernel) that calculates the covariance between data points. It is a function of the form k(x1,x2,hyperparameters, obj). The input x1 is a N1 x Di+Do array of positions, x2 is a N2 x Di+Do array of positions, the hyperparameters argument is a 1d array of length N depending on how many hyperparameters are initialized, and obj is an fvgp.GP instance. The default is a deep kernel with 2 hidden layers and a width of fvgp.fvGP.gp_deep_kernel_layer_width.

  • prior_mean_function (Callable, optional) – A function that evaluates the prior mean at a set of input position. It accepts as input an array of positions (of shape N1 x Di+Do), hyperparameters and a fvgp.GP instance. The return value is a 1d array of length N1. If None is provided, fvgp.GP._default_mean_function is used.

  • run_every_iteration (Callable, optional) – A function that is run at every iteration. It accepts as input a gpcam.AutonomousExperimenterGP instance. The default is a no-op.

  • x_data (np.ndarray, optional) – Initial data point positions.

  • y_data (np.ndarray, optional) – Initial data point values.

  • noise_variances (np.ndarray, optional) – Initial data point observation variances.

  • vp (np.ndarray, optional) – A 3d numpy array of shape (U x output_number x output_dim), so that for each measurement position, the outputs are clearly defined by their positions in the output space. The default is np.array([[0],[1],[2],[3],…,[output_number - 1]]) for each point in the input space. The default is only permissible if output_dim is 1.

  • communicate_full_dataset (bool, optional) – If True, the full dataset will be communicated to the instrument_function on each iteration. If False, only the newly suggested data points will be communicated. The default is False.

  • compute_device (str, optional) – One of “cpu” or “gpu”, determines how linear system solves are run. The default is “cpu”.

  • store_inv (bool, optional) – If True, the algorithm calculates and stores the inverse of the covariance matrix after each training or update of the dataset, which makes computing the posterior covariance faster. For larger problems (>2000 data points), the use of inversion should be avoided due to computational instability. The default is False. Note, the training will always use a linear solve instead of the inverse for stability reasons.

  • training_dask_client (distributed.client.Client, optional) – A Dask Distributed Client instance for distributed training. If None is provided, a new dask.distributed.Client instance is constructed.

  • acq_func_opt_dask_client (distributed.client.Client, optional) – A Dask Distributed Client instance for distributed acquisition_function computation. If None is provided, a new dask.distributed.Client instance is constructed.

  • info (bool, optional) – Specifies if info should be displayed. Default = False

x_data

Data point positions

Type:

np.ndarray

y_data

Data point values

Type:

np.ndarray

variances

Data point observation variances

Type:

np.ndarray

data.dataset

All data

Type:

list

hyperparameter_bounds

A 2d array of floats of size J x 2, such that J is the length matching the length of hyperparameters defining the bounds for training.

Type:

np.ndarray

gp_optimizer

A GPOptimizer instance used for initializing a Gaussian process and performing optimization of the posterior.

Type:

gpcam.GPOptimizer