Skip to content
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

FIX: SAELens new format has "scaling_factor" key, which causes assert to fail #39

Merged
merged 3 commits into from
Apr 20, 2024
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
8 changes: 5 additions & 3 deletions sae_vis/data_storing_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,14 +1016,16 @@ def create(

# If encoder isn't an AutoEncoder, we wrap it in one
if not isinstance(encoder, AutoEncoder):
assert (
set(encoder.state_dict().keys()) == {"W_enc", "W_dec", "b_enc", "b_dec"}
assert set(
encoder.state_dict().keys()
).issuperset(
{"W_enc", "W_dec", "b_enc", "b_dec"}
), "If encoder isn't an AutoEncoder, it should have weights 'W_enc', 'W_dec', 'b_enc', 'b_dec'"
d_in, d_hidden = encoder.W_enc.shape
device = encoder.W_enc.device
encoder_cfg = AutoEncoderConfig(d_in=d_in, d_hidden=d_hidden)
encoder_wrapper = AutoEncoder(encoder_cfg).to(device)
encoder_wrapper.load_state_dict(encoder.state_dict())
encoder_wrapper.load_state_dict(encoder.state_dict(), strict=False)
else:
encoder_wrapper = encoder

Expand Down