Skip to main content

core.PerInputCov

core.PerInputCov(blocks, event_shape=static())

Dense [N, E, E] blocks, one per input. Fine for classifiers with small C.

Parameters

Name Type Description Default
blocks Tensor The blocks, [N, E, E]. required
event_shape tuple[int, …] The shape of one input’s outputs; \(E\) is its product. static()

Methods

Name Description
diagonal The diagonals of the blocks, [N, *event_shape].
per_input blocks.
sample n_samples zero-mean draws through a symmetric square root of each block.
scaled The blocks times \(s\).

diagonal

core.PerInputCov.diagonal()

The diagonals of the blocks, [N, *event_shape].

Returns

Name Type Description
Tensor A tensor shaped like the mean.

per_input

core.PerInputCov.per_input()

blocks.

Returns

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

sample

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

n_samples zero-mean draws through a symmetric square root of each block.

The draws are independent across inputs. Negative eigenvalues of a block count as zero.

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 blocks’. None means torch’s global RNG. None

Returns

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

scaled

core.PerInputCov.scaled(s, /)

The blocks 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.