syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.posterior_state module

class syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.posterior_state.GaussProcAdditivePosteriorState(data, mean, kernel, noise_variance, **kwargs)[source]

Bases: PosteriorState

Represent posterior state for joint Gaussian model of learning curves over a number of configurations. The (additive) model is the sum of a Gaussian process model for function values at r_max and independent Gaussian models over r only.

Importantly, inference scales cubically only in the number of configurations, not in the number of observations.

property num_data
property num_features
property num_fantasies
neg_log_likelihood()[source]
Return type:

ndarray

Returns:

Negative log marginal likelihood

predict(test_features)[source]

We compute marginals over f(x, r), where test_features are extended features. Note: The test configs must not overlap with any in the training set. Otherwise, at least if r != r_max, the predictive distributions computed here may be wrong.

Parameters:

test_features (ndarray) – Extended features for test configs

Return type:

Tuple[ndarray, ndarray]

Returns:

posterior_means, posterior_variances

sample_marginals(test_features, num_samples=1, random_state=None)[source]

See comments of predict.

Parameters:
  • test_features (ndarray) – Input points for test configs

  • num_samples (int) – Number of samples

  • random_state (Optional[RandomState]) – PRNG

Return type:

ndarray

Returns:

Marginal samples, (num_test, num_samples)

backward_gradient(input, head_gradients, mean_data, std_data)[source]

Implements Predictor.backward_gradient, see comments there. This is for a single posterior state. If the Predictor uses MCMC, have to call this for every sample.

Parameters:
  • input (ndarray) – Single input point x, shape (d,)

  • head_gradients (Dict[str, ndarray]) – See Predictor.backward_gradient

  • mean_data (float) – Mean used to normalize targets

  • std_data (float) – Stddev used to normalize targets

Return type:

ndarray

Returns:

sample_curves(data, num_samples=1, random_state=None)[source]

Given data from one or more configurations (as returned by issm.prepare_data), for each config, sample a curve from the joint posterior (predictive) distribution over latent targets. The curve for each config in data may be partly observed, but must not be fully observed. Samples for the different configs are independent. None of the configs in data must appear in the dataset used to compute the posterior state.

The result is a list of dict, one for each config. If for a config, targets in data are given for resource values range(r_min, r_obs), the dict entry y is a joint sample [y_r], r in range(r_obs, r_max+1). For some subclasses (e.g., ISSM), there is also an entry f with a joint sample [f_r], r in range(r_obs-1, r_max+1), the latent function values before noise. These entries are matrices with num_samples columns, which are independent (the joint dependence is along the rows).

Parameters:
  • data (Dict[str, Any]) – Data for configs to predict at

  • num_samples (int) – Number of samples to draw from each curve

  • random_state (Optional[RandomState]) – PRNG state to be used for sampling

Return type:

List[dict]

Returns:

See above

static has_precomputations(data)[source]
Return type:

bool

class syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.posterior_state.IncrementalUpdateGPAdditivePosteriorState(data, mean, kernel, noise_variance, **kwargs)[source]

Bases: GaussProcAdditivePosteriorState

Extension of GaussProcAdditivePosteriorState which allows for incremental updating (single config added to the dataset). This is required for simulation-based scoring, and for support of fantasizing.

update(feature, targets)[source]
Return type:

IncrementalUpdateGPAdditivePosteriorState

update_pvec(feature, targets)[source]

Part of update: Only update prediction vector p. This cannot be used to update p for several new datapoints.

Parameters:
  • feature (ndarray) –

  • targets (ndarray) –

Return type:

ndarray

Returns:

New p vector

sample_and_update_for_pending(data_pending, sample_all_nonobserved=False, random_state=None)[source]

This function is needed for sampling fantasy targets, and also to support simulation-based scoring.

issm.prepare_data_with_pending creates two data dicts data_nopending, data_pending, the first for configs with observed data, but no pending evals, the second for configs with pending evals. You create the state with data_nopending, then call this method with data_pending.

This method is iterating over configs (or trials) in data_pending. For each config, it draws a joint sample from some non-observed targets, then updates the state conditioned on observed and sampled targets (by calling update). If sample_all_nonobserved is False, the number of targets sampled is the entry in data_pending['num_pending']. Otherwise, targets are sampled for all non-observed positions.

The method returns the list of sampled target vectors, and the state at the end (like update does as well).

Parameters:
  • data_pending (Dict[str, Any]) – See above

  • sample_all_nonobserved (bool) – See above

  • random_state (Optional[RandomState]) – PRNG

Return type:

(List[ndarray], IncrementalUpdateGPAdditivePosteriorState)

Returns:

pending_targets, final_state

class syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.posterior_state.GaussProcISSMPosteriorState(data, mean, kernel, iss_model, noise_variance, **kwargs)[source]

Bases: IncrementalUpdateGPAdditivePosteriorState

Represent posterior state for joint Gaussian model of learning curves over a number of configurations. The model is the sum of a Gaussian process model for function values at r_max and independent Gaussian linear innovation state space models (ISSMs) of a particular power law decay form.

static has_precomputations(data)[source]
Return type:

bool

predict(test_features)[source]

We compute marginals over f(x, r), where test_features are extended features. Note: The test configs must not overlap with any in the training set. Otherwise, at least if r != r_max, the predictive distributions computed here may be wrong.

Parameters:

test_features (ndarray) – Extended features for test configs

Return type:

Tuple[ndarray, ndarray]

Returns:

posterior_means, posterior_variances

static data_precomputations(data)[source]
update(feature, targets)[source]
Return type:

IncrementalUpdateGPAdditivePosteriorState

class syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.posterior_state.GaussProcExpDecayPosteriorState(data, mean, kernel, res_kernel, noise_variance, **kwargs)[source]

Bases: IncrementalUpdateGPAdditivePosteriorState

Represent posterior state for joint Gaussian model of learning curves over a number of configurations. The model is the sum of a Gaussian process model for function values at r_max and independent Gaussian processes over r, using an exponential decay covariance function. The latter is shared between all configs.

This is essentially the model from the Freeze Thaw paper (see also ExponentialDecayResourcesKernelFunction).

static has_precomputations(data)[source]
Return type:

bool

predict(test_features)[source]

We compute marginals over f(x, r), where test_features are extended features. Note: The test configs must not overlap with any in the training set. Otherwise, at least if r != r_max, the predictive distributions computed here may be wrong.

Parameters:

test_features (ndarray) – Extended features for test configs

Return type:

Tuple[ndarray, ndarray]

Returns:

posterior_means, posterior_variances

static data_precomputations(data)[source]
update(feature, targets)[source]
Return type:

IncrementalUpdateGPAdditivePosteriorState