Skip to content

Fix activation resampler normalization dimension #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def renormalize_and_scale(
# Calculate the average norm of the encoder weights for alive neurons.
detached_encoder_weight = encoder_weight.detach() # Don't track gradients
alive_encoder_weights: Float[
Tensor, Axis.names(Axis.LEARNT_FEATURE, Axis.INPUT_OUTPUT_FEATURE)
Tensor, Axis.names(Axis.ALIVE_FEATURE, Axis.INPUT_OUTPUT_FEATURE)
] = detached_encoder_weight[alive_neuron_mask, :]
average_alive_norm: Float[Tensor, Axis.SINGLE_ITEM] = alive_encoder_weights.norm(
dim=-1
Expand Down Expand Up @@ -416,7 +416,7 @@ def resample_dead_neurons(
# vector for the dead autoencoder neuron.
renormalized_input: Float[
Tensor, Axis.names(Axis.DEAD_FEATURE, Axis.INPUT_OUTPUT_FEATURE)
] = torch.nn.functional.normalize(sampled_input, dim=0)
] = torch.nn.functional.normalize(sampled_input, dim=-1)
dead_decoder_weight_updates = rearrange(
renormalized_input, "dead_neuron input_feature -> input_feature dead_neuron"
)
Expand Down