multigeom.encoders.registry#

Registries of backbones and readouts, by name.

An encoder is saved with a description of its architecture (which backbone and readout,
with which arguments) next to its weights, so that `NeuralEncoder.load` can rebuild it.
The description refers to classes by their registered name:

    @register_backbone("my_cnn")
    class MyCNN(nn.Module):
        out_channels, out_spatial = 32, 16
        def __init__(self, width: int = 32): ...

The decorator also records the arguments each instance was created with. Backbones need
the attributes `out_channels` and `out_spatial` (the shape [B, C, S, S] of their
output), which the readout is sized from.

Functions

describe(module, registry, kind)

{"name": ..., "kwargs": {...}} of a registered backbone or readout instance, for the saved architecture.

register_backbone(name)

Class decorator: make a backbone available under name (needed to save and reload an encoder that uses it).

register_readout(name)

Class decorator: make a readout available under name.