# Reference

## Front door

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

|  |  |
|----|----|
| [kfac, diagonal, plan](../reference/front_door.llms.md) | KFAC, the GGN diagonal, and what they would do, with defaults. |
| [Plan](../reference/Plan.llms.md#hessiankit.Plan) | What `hk.kfac` or `hk.diagonal` would compute on a batch, and why, without computing. |
| [LayerInfo](../reference/LayerInfo.llms.md#hessiankit.LayerInfo) | One layer the front door computes for. |
| [Batch](../reference/Batch.llms.md#hessiankit.Batch) | `(inputs, targets)` or `(inputs, targets, weights)`; `targets` may be `None`. |
| [EXACT_MAX_PASSES](../reference/EXACT_MAX_PASSES.llms.md#hessiankit.EXACT_MAX_PASSES) | Exact factors when they take at most this many backward passes per batch, else MC. |
| [MC_SAMPLES](../reference/MC_SAMPLES.llms.md#hessiankit.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](../reference/compute.llms.md#hessiankit.compute) | `compute`: one forward, one backward pass per output factor, and the reductions. |
| [KFACType](../reference/KFACType.llms.md#hessiankit.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](../reference/Result.llms.md#hessiankit.Result) | What `compute` returns: per layer, the diagonal and the KFAC factors it asked for. |
| [LayerDiagonal](../reference/LayerDiagonal.llms.md#hessiankit.LayerDiagonal) | The exact GGN diagonal of one layer, summed over a batch. |
| [LayerKron](../reference/LayerKron.llms.md#hessiankit.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](../reference/OutputFactors.llms.md#hessiankit.OutputFactors) | Vectors at the model output whose signed outer products sum to the output Hessian. |
| [categorical](../reference/categorical.llms.md#hessiankit.categorical) | Factors of the softmax cross-entropy loss. |
| [bernoulli](../reference/bernoulli.llms.md#hessiankit.bernoulli) | Factors of the sigmoid binary cross-entropy loss. |
| [gaussian](../reference/gaussian.llms.md#hessiankit.gaussian) | Factors of the Gaussian negative log-likelihood, whose Hessian is `diag(1 / sigma^2)`. |
| [from_dense](../reference/from_dense.llms.md#hessiankit.from_dense) | Factors of any per-example output Hessian, through its eigendecomposition. |
| [Fisher](../reference/Fisher.llms.md#hessiankit.Fisher) | Which matrix the factors stand for: the Hessian, its MC estimate, or the empirical Fisher. |
| [Kind](../reference/Kind.llms.md#hessiankit.Kind) | The same as `Fisher`, the name the helpers’ `kind` argument uses. |
| [Grouping](../reference/Grouping.llms.md#hessiankit.Grouping) | How exact factors of several positions are grouped. |

## Likelihoods

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

|  |  |
|----|----|
| [Likelihood](../reference/Likelihood.llms.md#hessiankit.Likelihood) | What the front door needs from a likelihood. |
| [Categorical, Bernoulli, Gaussian, FromHessian](../reference/likelihoods.llms.md) | The built-in likelihoods. |

## Layer rules

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

|  |  |
|----|----|
| [LayerRule](../reference/LayerRule.llms.md#hessiankit.LayerRule) | Turns a layer’s input and output gradient into the canonical form. |
| [LinearRule](../reference/LinearRule.llms.md#hessiankit.LinearRule) | Rule for `nn.Linear` on inputs `[N, D]` or `[N, *positions, D]`. |
| [Conv2dRule](../reference/Conv2dRule.llms.md#hessiankit.Conv2dRule) | Rule for `nn.Conv2d` on inputs `[N, C, H, W]`. |
| [DEFAULT_RULES](../reference/DEFAULT_RULES.llms.md#hessiankit.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](../reference/HessiankitError.llms.md#hessiankit.HessiankitError) | Base class for every error hessiankit raises. |
| [UnsupportedLayerError](../reference/UnsupportedLayerError.llms.md#hessiankit.UnsupportedLayerError) | A layer path names no module, or no rule covers the layer’s type or its input shape. |
| [CaptureError](../reference/CaptureError.llms.md#hessiankit.CaptureError) | A requested layer could not be captured. |
| [FunctionalReuseError](../reference/FunctionalReuseError.llms.md#hessiankit.FunctionalReuseError) | Autograd’s gradient for a layer differs from the one built from the captured tensors. |
| [FactorError](../reference/FactorError.llms.md#hessiankit.FactorError) | Factor, mask or weight shapes are inconsistent, or KFAC got negative signs. |
