peal.sparse_dictionaries.batch_topk_network.SparseAutoencoderBase¶
- class peal.sparse_dictionaries.batch_topk_network.SparseAutoencoderBase[source]¶
Bases:
ModuleShared parameters and housekeeping of a tied-init sparse autoencoder.
- Parameters:
cfg (
dict) – Needsseed,act_size,dict_size,device,dtypeandinput_unit_norm.- Variables:
W_enc (
torch.nn.Parameter) –(act_size, dict_size)encoder weight.W_dec (
torch.nn.Parameter) –(dict_size, act_size)decoder weight; rows are the dictionary atoms and are kept unit-norm during training.b_dec (b_enc,) – Encoder and decoder biases.
num_batches_not_active (
torch.Tensor) – Per-atom count of consecutive batches with no activation, used to find dead atoms.
Methods
Undo
preprocess_input()on a reconstruction.Optionally standardise each row; returns
(x, mean, std).- postprocess_output(x_reconstruct, x_mean, x_std)[source]¶
Undo
preprocess_input()on a reconstruction.
- make_decoder_weights_and_grad_unit_norm()¶
Project the decoder rows back to the unit sphere, and remove the radial component of their gradient so the optimiser step stays tangential.
- update_inactive_features(acts)¶
Increment the dead-atom counters for atoms unused in this batch.