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
- 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 ifr != 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 configsnum_samples (
int
) – Number of samplesrandom_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_gradientmean_data (
float
) – Mean used to normalize targetsstd_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 indata
may be partly observed, but must not be fully observed. Samples for the different configs are independent. None of the configs indata
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 entryy
is a joint sample [y_r], r in range(r_obs, r_max+1). For some subclasses (e.g., ISSM), there is also an entryf
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 withnum_samples
columns, which are independent (the joint dependence is along the rows).- Parameters:
data (
Dict
[str
,Any
]) – Data for configs to predict atnum_samples (
int
) – Number of samples to draw from each curverandom_state (
Optional
[RandomState
]) – PRNG state to be used for sampling
- Return type:
List
[dict
]- Returns:
See above
- 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_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 dictsdata_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 withdata_nopending
, then call this method withdata_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 callingupdate
). Ifsample_all_nonobserved
is False, the number of targets sampled is the entry indata_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 abovesample_all_nonobserved (
bool
) – See aboverandom_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.
- 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 ifr != 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
- 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
).- 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 ifr != 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