whitening#
unscent_warp#
- pyvbmc.whitening.unscent_warp(fun, x, sigma)[source]#
Compute the unscented transform of the warping function fun.
- Parameters:
- funfunction
A single-argument function which warps input points.
- x(n,D) or (D,) np.ndarray
The input mean for which to compute the unscented transform. A single row is broadcast against the rows of sigma.
- sigma(n,D) or (D,) np.ndarray
The input matrix of standard deviations or scale parameters for which to compute the unscented transform. A single row is broadcast against the rows of x.
- Returns:
- x_warped_mean(n,D) or (D,) np.ndarray
The unscented estimate of the mean, with one row per row of the broadcast inputs. It is one-dimensional where x is and the inputs give a single row.
- x_warped_sigma(n,D) or (D,) np.ndarray
The unscented estimate of the standard deviation / scale parameters, shaped like x_warped_mean.
- x_warped(U,n,D) np.ndarray
The warped mean points at x_warped[0, :, :], and the warped std. simplex points, at [1:, :, :]. Here U=2*D+1.
- Raises:
- ValueError
If the rows/columns of x and sigma cannot be coerced to match.
warp_input#
- pyvbmc.whitening.warp_input(vp, optim_state, function_logger, options)[source]#
Compute input warping of variables and update the cached points in function_logger accordingly.
Currently supports only a whitening transformation: a rotation and rescaling of the inference space such that the variational posterior achieves unit diagonal covariance.
- Parameters:
- vpVariationalPosterior
The variational posterior whose covariance the whitening transformation is computed from. That covariance is expressed in the inference space of the posterior’s own parameter transformer, which need not be the space the run is currently in.
- optim_statedict
The dictionary recording the current optimization state.
- function_loggerFunctionLogger
The record including cached function values. Its parameter transformer defines the current inference space, the one the search bounds and the cached search points are given in.
- optionsOptions
The options of the run:
warp_rotoscaling,warp_roto_corr_threshandwarp_cov_regare read.
- Returns:
- parameter_transformerParameterTransformer
A ParameterTransformer object representing the new transformation between original coordinates and inference space coordinates, with the input warping applied.
- optim_statedict
An updated copy of the original optimization state dict.
- function_loggerFunctionLogger
An updated copy of the original function logger.
- warp_actionstr
The label of the warp in the iteration display, “rotoscale”.
- Raises:
- ValueError
If
warp_cov_regis neither a finite real number nor a function of the number of training points that returns one.
Notes
Random draws use
vp.rng.
warp_gp_and_vp#
- pyvbmc.whitening.warp_gp_and_vp(parameter_transformer, gp_old, vp_old, vbmc)[source]#
Update the GP and VP with a given warp transformation.
Applies an updated ParameterTransformer object (with new warping transformation) to the GP and VP parameters.
- Parameters:
- parameter_transformerParameterTransformer
The new (warped) transformation between input coordinates and inference coordinates.
- gp_oldgpr.GP
The current Gaussian process.
- vp_oldVariationalPosterior
The current variational posterior.
- vbmcVBMC
The current VBMC object.
- Returns:
- vpVariationalPosterior
An updated copy of the original variational posterior.
- hyp_warpednp.ndarray
The GP hyperparameters with the warping transformation applied, one row per hyperparameter sample, of shape
(Ns_gp, n_hyp).
- Raises:
- ValueError
If the mean function of the GP is none of the zero, constant and negative quadratic means.