Skip to main content

Reference

Front door

One call over the batches, with defaults from the likelihood and the output’s shape.

kfac, diagonal, plan KFAC, the GGN diagonal, and what they would do, with defaults.
Plan What hk.kfac or hk.diagonal would compute on a batch, and why, without computing.
LayerInfo One layer the front door computes for.
Batch (inputs, targets) or (inputs, targets, weights); targets may be None.
EXACT_MAX_PASSES Exact factors when they take at most this many backward passes per batch, else MC.
MC_SAMPLES Monte Carlo samples per example by method, unless mc_samples is given.

Compute

One forward, one backward pass per output factor, and the reductions.

compute compute: one forward, one backward pass per output factor, and the reductions.
KFACType How KFAC treats several positions per example: expand them as examples, or sum them.

Results

Per-batch sums that add, with the total weight of the examples that counted.

Result What compute returns: per layer, the diagonal and the KFAC factors it asked for.
LayerDiagonal The exact GGN diagonal of one layer, summed over a batch.
LayerKron The KFAC factors of one layer, summed over a batch.

Output factors

Vectors at the model output whose outer products sum to the loss Hessian.

OutputFactors Vectors at the model output whose signed outer products sum to the output Hessian.
categorical Factors of the softmax cross-entropy loss.
bernoulli Factors of the sigmoid binary cross-entropy loss.
gaussian Factors of the Gaussian negative log-likelihood, whose Hessian is diag(1 / sigma^2).
from_dense Factors of any per-example output Hessian, through its eigendecomposition.
Fisher Which matrix the factors stand for: the Hessian, its MC estimate, or the empirical Fisher.
Kind The same as Fisher, the name the helpers’ kind argument uses.
Grouping How exact factors of several positions are grouped.

Likelihoods

Output factors together with the output’s event axes and void labels.

Likelihood What the front door needs from a likelihood.
Categorical, Bernoulli, Gaussian, FromHessian The built-in likelihoods.

Layer rules

A layer’s input and output gradient in the canonical form the reductions use.

LayerRule Turns a layer’s input and output gradient into the canonical form.
LinearRule Rule for nn.Linear on inputs [N, D] or [N, *positions, D].
Conv2dRule Rule for nn.Conv2d on inputs [N, C, H, W].
DEFAULT_RULES The built-in rules by layer type. Read-only: to add a rule, pass a new mapping.

Errors

What hessiankit raises. Every error is a HessiankitError.

HessiankitError Base class for every error hessiankit raises.
UnsupportedLayerError A layer path names no module, or no rule covers the layer’s type or its input shape.
CaptureError A requested layer could not be captured.
FunctionalReuseError Autograd’s gradient for a layer differs from the one built from the captured tensors.
FactorError Factor, mask or weight shapes are inconsistent, or KFAC got negative signs.