covmats.CovViaCholesky.colorize_adjoint#

CovViaCholesky.colorize_adjoint(y)#

Perform the adjoint (transpose) of the colorizing transformation.

If colorize(x) = L @ x (writing the colorizer as a linear map \(L\) from white-noise space, dimension subspace_size, to data space, dimension n_pts), this returns \(L^T y\). It never squares or inverts the transform: this is not the whitening operation, and it is generally not equal to colorize even when L is square (unless L happens to be symmetric), since colorize is typically triangular, orthogonal-like, or a rectangular low-rank factor rather than symmetric.

This is primarily useful for backpropagating gradients through a colorizing transform, e.g. when x (or a deterministic function of it, such as a gradual-deformation combination of several white noises) is itself the result of an upstream computation being differentiated: if field = cov.colorize(x) and grad_field is the gradient of some objective w.r.t. field, then cov.colorize_adjoint(grad_field) is the gradient of that objective w.r.t. x.

Parameters:

y (array_like) – An array of points in data space. The last dimension must equal n_pts.

Returns:

y_ – The transformed array, with its last dimension equal to subspace_size.

Return type:

array_like

Examples

>>> import numpy as np
>>> import covmats
>>> rng = np.random.default_rng(0)
>>> n = 4
>>> A = rng.random(size=(n, n))
>>> cov_array = A @ A.T + n * np.eye(n)
>>> L = np.linalg.cholesky(cov_array)
>>> cov = covmats.CovViaCholesky(L)
>>> x = rng.standard_normal(n)
>>> y = rng.standard_normal(n)
>>> np.allclose(cov.colorize(x) @ y, x @ cov.colorize_adjoint(y))
True