multigeom.fit.train_encoder#

The paper’s recipe for fitting an encoder to macaque recordings: load the 50 most reliable channels of V1 or V4 from the THINGS Ventral-stream Spiking Dataset (Papale et al.), build a reference encoder (Inception, ResNet-50 or ON-OFF backbone, Gaussian readout), fit its readout and score it on the test images.

This module holds only what is specific to that dataset. The readout is fitted by
`NeuralEncoder.fit_readout` (`multigeom.encoders.fitting`), the same method as for any
other data, and the checkpoint is written by `NeuralEncoder.save`: the weights and
architecture, with the test scores (`per_neuron_test_corr`, `test_predictions`,
`oracle`, ...) in its metadata, which the figure and table code read (Fig. 3B-C, Fig.
4A, Table 1).

With --evaluate-only, an existing encoder (--encoder-ckpt) is not trained: it is run on
the TVSD test images and written to --out-dir with its test scores. Only the test images
are needed.

Usage:
    python -m multigeom.fit.train_encoder \
        --config inception --area V1 \
        --device cuda:0 \
        --out-dir runs/encoders/inception/V1

    python -m multigeom.fit.train_encoder \
        --config inception --area V1 --evaluate-only \
        --encoder-ckpt runs/encoders/inception/V1/best_model.pt \
        --out-dir runs/encoders/inception/V1

Functions

checkpoint_scores(path)

The fit scores an existing checkpoint carries (val_corr, best_epoch), in either checkpoint layout.

main([argv])

Fit the readout of an encoder to the TVSD recordings, or evaluate a checkpoint (command-line entry point).

parse_args([argv])

Command-line arguments of python -m multigeom.fit.train_encoder.

print_test_summary(fields)

Print the mean, median and range of the per-neuron test correlations.

test_set_fields(test_pred, test_resp, oracle)

Test-set entries stored in an encoder checkpoint.