peal.sparse_dictionaries.probe_sparse_autoencoder.ProbeSAE

class peal.sparse_dictionaries.probe_sparse_autoencoder.ProbeSAE[source]

Bases: SparseDictionary

Dictionary whose atoms are the rows of a classifier’s last linear layer.

Parameters:

config (ProbeSAEConfig) – Points to the checkpoint; fc.weight is cloned into self.W with shape (n_classes, feature_dim), and self.mu is a zero mean vector of length feature_dim so callers treating the dictionary as centered get an identity offset.

Methods

fit

No-op: the probe weights are fixed by the checkpoint.

fit_from_dataloaders

No-op: the probe weights are fixed by the checkpoint.

get_components

Return the atoms as columns, i.e. W.t() of shape (D, n_classes).

load_from_disk

Restore self.W from a file written by save_on_disk().

save_on_disk

Save {"W": self.W} with torch.save to path.

Attributes

config

__init__(config)[source]

Load the checkpoint on CPU and copy its fc weight matrix.

fit(X)[source]

No-op: the probe weights are fixed by the checkpoint.

fit_from_dataloaders(dataloaders, feature_extractor)[source]

No-op: the probe weights are fixed by the checkpoint.

get_components()[source]

Return the atoms as columns, i.e. W.t() of shape (D, n_classes).

save_on_disk(path)[source]

Save {"W": self.W} with torch.save to path.

load_from_disk(path)[source]

Restore self.W from a file written by save_on_disk().