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 state for further processing. The entries configs, targets of the result dict are lists of one entry per trial, they are sorted in decreasing order of number of target values. features is the feature matrix corresponding to configs. If normalize_targets is True, the target values are normalized to mean 0, variance 1 (over all values), and mean_targets, std_targets is returned.

If do_fantasizing is True, state.pending_evaluations is also taken into account. Entries there have to be of type FantasizedPendingEvaluation. 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 the targets list 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 in state.pending_evaluations are not normalized, because they are assumed to be sampled from the posterior with normalized targets as well.

Parameters:
  • state (TuningJobState) – TuningJobState with data

  • config_space_ext (ExtendedConfiguration) – Extended config space

  • active_metric (str) –

  • normalize_targets (bool) – See above

  • do_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_data with do_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 entry num_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) – See prepare_data

  • config_space_ext (ExtendedConfiguration) – See prepare_data

  • active_metric (str) – See prepare_data

  • normalize_targets (bool) – See prepare_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_data orders datapoints by nonincreasing number of targets ydims[i]. For 0 <= j < ydim_max, ydim_max = ydims[0] = max(ydims), num_configs[j] is the number of datapoints i for which ydims[i] > j. deltay is a flat matrix (rows corresponding to fantasy samples; column vector if no fantasizing) consisting of ydim_max parts, where part j is of size num_configs[j] and contains y[j] - y[j-1] for targets of those i counted in num_configs[j], the term needed in the recurrence to compute w[j]. ‘logr`` is a flat vector consisting of ydim_max - 1 parts, where part j (starting from 1) is of size num_configs[j] and contains the logarithmic term for computing a[j-1] and e[j].

Parameters:
  • targets (List[ndarray]) – Targets from data representation returned by prepare_data

  • r_min (int) – Value of r_min, as returned by prepare_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 precomputed from issm_likelihood_precomputations and ISSM parameters issm_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 of issm_likelihood_precomputations

  • issm_params (Dict) – Parameters of ISSM likelihood

  • r_min (int) – Smallest resource value

  • r_max (int) – Largest resource value

  • skip_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., if issm_likelihood contains wtw).

Parameters:
  • features – Input matrix X

  • mean – Mean function

  • kernel – Kernel function

  • issm_likelihood (Dict) – Outcome of issm_likelihood_computations

  • noise_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_means is a (n, F) matrix, where F is the number of fantasy samples, or F == 1 without fantasizing.

Parameters:
  • poster_state (Dict) – Posterior state

  • mean – 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_params are likelihood parameters for the test configs. posterior_means is a (n, F) matrix, where F is the number of fantasy samples, or F == 1 without fantasizing.

Parameters:
  • poster_state (Dict) – Posterior state

  • mean – Mean function

  • kernel – Kernel function

  • test_features – Feature matrix for test points (not extended)

  • resources (List[int]) – Resource values corresponding to rows of test_features

  • issm_params (Dict) – See above

  • r_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_state for 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. targets may be empty, but must not reach all the way to r_max. The additional configuration must not be in the dataset used to compute poster_state.

If targets correspond 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. targets empty), in which case both [y_r] and [f_r] ranges in range(r_min, r_max+1). We return a dict with [f_r] under f, [y_r] under y. These are matrices with num_samples columns.

Parameters:
  • poster_state (Dict) – Posterior state for data

  • mean – Mean function

  • kernel – Kernel function

  • feature – Features for additional config

  • targets (ndarray) – Target values for additional config

  • issm_params (Dict) – Likelihood parameters for additional config

  • r_min (int) – Smallest resource value

  • r_max (int) – Largest resource value

  • random_state (RandomState) – numpy.random.RandomState

  • num_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_new respectively. r4vec and pvec are extended and all entries change. The new datapoint is represented by feature, d_new, s_new, r2_new.

Note: The field criterion is not updated, but set to np.nan.

Parameters:
  • poster_state (Dict) – Posterior state for data

  • kernel – 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) – See update_posterior_state

  • kernel – See update_posterior_state

  • feature – See update_posterior_state

  • d_new – See update_posterior_state

  • s_new – See update_posterior_state

  • r2_new – See update_posterior_state

Return type:

ndarray

Returns:

New p vector, as flat vector