Result
Result(diagonal=dict(), kron=dict(), uncovered=dict())What compute returns: per layer, the diagonal and the KFAC factors it asked for.
+ adds two results layer by layer. A layer in only one of them is kept as is, so Result() is the identity.
Attributes
| Name | Type | Description |
|---|---|---|
| diagonal | Mapping[str, LayerDiagonal] | LayerDiagonal by layer path. |
| kron | Mapping[str, LayerKron] | LayerKron by layer path. |
| uncovered | Mapping[str, str] | Trainable parameters no layer covers, by name, each with the reason. compute leaves it empty; + takes the union. |
Methods
| Name | Description |
|---|---|
| by_parameter | The diagonal by parameter name: "<layer>.weight" and "<layer>.bias". |
by_parameter
Result.by_parameter()The diagonal by parameter name: "<layer>.weight" and "<layer>.bias".
The order is that of diagonal, each layer’s weight before its bias. Concatenating the flattened values gives the same vector as the layers’ flat() in turn.
Examples
>>> import torch, hessiankit as hk
>>> d = hk.LayerDiagonal(torch.ones(3, 4), torch.ones(3), torch.tensor(1.0))
>>> list(hk.Result(diagonal={"head": d}).by_parameter())
['head.weight', 'head.bias']