Skip to main content

core.OutputCov

core.OutputCov()

Covariance of model outputs for a batch of inputs, never formed as an \(NE \times NE\) matrix.

Shapes follow the mean, for example [N, C] for \(N\) inputs, and \(E\) is the flattened event size. per_input() holds no cross-input blocks; sample may draw jointly across the batch (SampleCov, FactorCov: one weight draw per sample).

Methods

Name Description
diagonal The marginal variances.
per_input The covariance block of each input, without the cross-input blocks.
sample Zero-mean draws from the covariance.
scaled The covariance times \(s\).

diagonal

core.OutputCov.diagonal()

The marginal variances.

Returns

Name Type Description
Tensor A tensor shaped like the mean.

per_input

core.OutputCov.per_input()

The covariance block of each input, without the cross-input blocks.

Returns

Name Type Description
Tensor The blocks, [N, E, E].

Raises

Name Type Description
StructureError Implementations may raise it when \(E\) is too large for dense blocks, as SampleCov and FactorCov do above MAX_DENSE_EVENT.

sample

core.OutputCov.sample(n_samples, /, *, generator=None)

Zero-mean draws from the covariance.

Parameters

Name Type Description Default
n_samples int Number of draws. required
generator torch.Generator | None The generator to draw with, on any device: the draws move to the covariance’s. None means torch’s global RNG. None

Returns

Name Type Description
Tensor The draws, [n_samples, *mean.shape].

Raises

Name Type Description
ValueError Implementations may raise it when they can’t give n_samples draws, as SampleCov does.

scaled

core.OutputCov.scaled(s, /)

The covariance times \(s\).

Parameters

Name Type Description Default
s Tensor The factor \(s \ge 0\), a 0-dim tensor. required

Returns

Name Type Description
Self A covariance of the same type.