ksddescent.svgd

ksddescent.svgd(x0, score, step, max_iter=1000, bw=1, tol=1e-05, verbose=False, store=False, backend='auto')

Stein Variational Gradient Descent

Sample by optimization with the Stein Variational Gradient Descent with a Gaussian kernel.

Parameters
x0torch.tensor or numpy.ndarray, size n_samples x n_features

initial positions

scorecallable

function that computes the score. Must be compatible with the backend.

stepfloat

step size

max_iterint

max numer of iters

bwfloat

bandwidth of the Stein kernel

tolfloat

tolerance for stopping the algorithm. The algorithm stops when the norm of the SVDG direction is below tol.

storebool

whether to store the iterates

verbosebool

whether to print the current loss

backendstr, ‘auto’, ‘numpy’ or ‘torch’

Chooses the backend for the algorithm: numpy or torch. If numpy, x0 must be a numpy array and score must map numpy array to numpy array. If torch, x0 must be a torch tensor and score must map torch tensor to torch tensor. If auto, the backend is infered from the type of x0.

Returns
x: torch.tensor or np.ndarray

The final positions

References

Q. Liu, D. Wang. Stein variational gradient descent: A general purpose Bayesian inference algorithm, Advances In Neural Information Processing Systems, 2370-2378