syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm module
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.prepare_data(state, config_space_ext, active_metric, normalize_targets=False, do_fantasizing=False)[source]
Prepares data in
statefor further processing. The entriesconfigs,targetsof the result dict are lists of one entry per trial, they are sorted in decreasing order of number of target values.featuresis the feature matrix corresponding toconfigs. Ifnormalize_targetsis True, the target values are normalized to mean 0, variance 1 (over all values), andmean_targets,std_targetsis returned.If
do_fantasizingis True,state.pending_evaluationsis also taken into account. Entries there have to be of typeFantasizedPendingEvaluation. Also, in terms of their resource levels, they need to be adjacent to observed entries, so there are no gaps. In this case, the entries of thetargetslist are matrices, each column corr´esponding to a fantasy sample.Note: If
normalize_targets, mean and stddev are computed over observed values only. Also, fantasy values instate.pending_evaluationsare not normalized, because they are assumed to be sampled from the posterior with normalized targets as well.- Parameters:
state (
TuningJobState) –TuningJobStatewith dataconfig_space_ext (
ExtendedConfiguration) – Extended config spaceactive_metric (
str)normalize_targets (
bool) – See abovedo_fantasizing (
bool) – See above
- Return type:
Dict- Returns:
See above
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.prepare_data_with_pending(state, config_space_ext, active_metric, normalize_targets=False)[source]
Similar to
prepare_datawithdo_fantasizing=False, but two dicts are returned, the first for trials without pending evaluations, the second for trials with pending evaluations. The latter dict also contains trials which have pending, but no observed evaluations. The second dict has the additional entrynum_pending, which lists the number of pending evals for each trial. These evals must be contiguous and adjacent with observed evals, so that the union of observed and pending evals are contiguous (when it comes to resource levels).- Parameters:
state (
TuningJobState) – Seeprepare_dataconfig_space_ext (
ExtendedConfiguration) – Seeprepare_dataactive_metric (
str) – Seeprepare_datanormalize_targets (
bool) – Seeprepare_data
- Return type:
(
Dict,Dict)- Returns:
See above
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.issm_likelihood_precomputations(targets, r_min)[source]
Precomputations required by
issm_likelihood_computations.Importantly,
prepare_dataorders datapoints by nonincreasing number of targetsydims[i]. For0 <= j < ydim_max,ydim_max = ydims[0] = max(ydims),num_configs[j]is the number of datapoints i for whichydims[i] > j.deltayis a flat matrix (rows corresponding to fantasy samples; column vector if no fantasizing) consisting ofydim_maxparts, where part j is of sizenum_configs[j]and containsy[j] - y[j-1]for targets of those i counted innum_configs[j], the term needed in the recurrence to computew[j]. ‘logr`` is a flat vector consisting ofydim_max - 1parts, where part j (starting from 1) is of sizenum_configs[j]and contains the logarithmic term for computinga[j-1]ande[j].- Parameters:
targets (
List[ndarray]) – Targets from data representation returned byprepare_datar_min (
int) – Value of r_min, as returned byprepare_data
- Return type:
Dict- Returns:
See above
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.issm_likelihood_computations(precomputed, issm_params, r_min, r_max, skip_c_d=False)[source]
Given
precomputedfromissm_likelihood_precomputationsand ISSM parametersissm_params, compute quantities required for inference and marginal likelihood computation, pertaining to the ISSM likelihood.The index for r is range(r_min, r_max + 1). Observations must be contiguous from r_min. The ISSM parameters are: - alpha: n-vector, negative - beta: n-vector - gamma: scalar, positive
Results returned are: - c: n vector [c_i], negative - d: n vector [d_i], positive - vtv: n vector [|v_i|^2] - wtv: (n, F) matrix [(W_i)^T v_i], F number of fantasy samples - wtw: n-vector [|w_i|^2] (only if no fantasizing)
- Parameters:
precomputed (
Dict) – Output ofissm_likelihood_precomputationsissm_params (
Dict) – Parameters of ISSM likelihoodr_min (
int) – Smallest resource valuer_max (
int) – Largest resource valueskip_c_d (
bool) – If True, c and d are not computed
- Return type:
Dict- Returns:
Quantities required for inference and learning criterion
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.posterior_computations(features, mean, kernel, issm_likelihood, noise_variance)[source]
Computes posterior state (required for predictions) and negative log marginal likelihood (returned in
criterion), The latter is computed only when there is no fantasizing (i.e., ifissm_likelihoodcontainswtw).- Parameters:
features – Input matrix X
mean – Mean function
kernel – Kernel function
issm_likelihood (
Dict) – Outcome ofissm_likelihood_computationsnoise_variance – Variance of ISSM innovations
- Return type:
Dict- Returns:
Internal posterior state
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.predict_posterior_marginals(poster_state, mean, kernel, test_features)[source]
These are posterior marginals on the h variable, whereas the full model is for f_r = h + g_r (additive).
posterior_meansis a (n, F) matrix, where F is the number of fantasy samples, or F == 1 without fantasizing.- Parameters:
poster_state (
Dict) – Posterior statemean – Mean function
kernel – Kernel function
test_features – Feature matrix for test points (not extended)
- Returns:
posterior_means, posterior_variances
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.sample_posterior_marginals(poster_state, mean, kernel, test_features, random_state, num_samples=1)[source]
We sample from posterior marginals on the h variance, see also
predict_posterior_marginals.
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.predict_posterior_marginals_extended(poster_state, mean, kernel, test_features, resources, issm_params, r_min, r_max)[source]
These are posterior marginals on f_r = h + g_r variables, where (x, r) are zipped from
test_features,resources.issm_paramsare likelihood parameters for the test configs.posterior_meansis a (n, F) matrix, where F is the number of fantasy samples, or F == 1 without fantasizing.- Parameters:
poster_state (
Dict) – Posterior statemean – Mean function
kernel – Kernel function
test_features – Feature matrix for test points (not extended)
resources (
List[int]) – Resource values corresponding to rows oftest_featuresissm_params (
Dict) – See abover_min (
int)r_max (
int)
- Returns:
posterior_means, posterior_variances
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.sample_posterior_joint(poster_state, mean, kernel, feature, targets, issm_params, r_min, r_max, random_state, num_samples=1)[source]
Given
poster_statefor some data plus one additional configuration with data (feature,targets,issm_params), draw joint samples of the latent variables not fixed by the data, and of the latent target values.targetsmay be empty, but must not reach all the way tor_max. The additional configuration must not be in the dataset used to computeposter_state.If
targetscorrespond to resource values range(r_min, r_obs), we sample latent target values y_r corresponding to range(r_obs, r_max+1) and latent function values f_r corresponding to range(r_obs-1, r_max+1), unless r_obs = r_min (i.e.targetsempty), in which case both [y_r] and [f_r] ranges in range(r_min, r_max+1). We return a dict with [f_r] underf, [y_r] undery. These are matrices withnum_samplescolumns.- Parameters:
poster_state (
Dict) – Posterior state for datamean – Mean function
kernel – Kernel function
feature – Features for additional config
targets (
ndarray) – Target values for additional configissm_params (
Dict) – Likelihood parameters for additional configr_min (
int) – Smallest resource valuer_max (
int) – Largest resource valuerandom_state (
RandomState) – numpy.random.RandomStatenum_samples (
int) – Number of joint samples to draw (default: 1)
- Return type:
Dict- Returns:
See above
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.issm_likelihood_slow_computations(targets, issm_params, r_min, r_max, skip_c_d=False)[source]
Naive implementation of
issm_likelihood_computations, which does not require precomputations, but is much slower. Here, results are computed one datapoint at a time, instead of en bulk.This code is used in unit testing, and called from
sample_posterior_joint.- Return type:
Dict
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.update_posterior_state(poster_state, kernel, feature, d_new, s_new, r2_new)[source]
Incremental update of posterior state, given data for one additional configuration. The new datapoint gives rise to a new row/column of the Cholesky factor. r2vec and svec are extended by
r2_new,s_newrespectively. r4vec and pvec are extended and all entries change. The new datapoint is represented byfeature,d_new,s_new,r2_new.Note: The field
criterionis not updated, but set to np.nan.- Parameters:
poster_state (
Dict) – Posterior state for datakernel – Kernel function
feature – Features for additional config
d_new – See above
s_new – See above
r2_new – See above
- Return type:
Dict- Returns:
Updated posterior state
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd.learncurve.issm.update_posterior_pvec(poster_state, kernel, feature, d_new, s_new, r2_new)[source]
Part of
update_posterior_state, just returns the new p vector.- Parameters:
poster_state (
Dict) – Seeupdate_posterior_statekernel – See
update_posterior_statefeature – See
update_posterior_stated_new – See
update_posterior_states_new – See
update_posterior_stater2_new – See
update_posterior_state
- Return type:
ndarray- Returns:
New p vector, as flat vector