-
Notifications
You must be signed in to change notification settings - Fork 15
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
[WIP] Add label-free qleace #16
base: main
Are you sure you want to change the base?
Conversation
4f337c1
to
ecb5c47
Compare
ecb5c47
to
d23513a
Compare
concept_erasure/alf_qleace.py
Outdated
# Find the class that has the difference with the largest singular | ||
# value (spectral norm) | ||
svds: list[tuple[Tensor, Tensor, Tensor]] = [ | ||
torch.svd_lowrank(sigma_xx_z_diffs[i], q=1) for i in range(self.z_dim) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
increase svd iterations to 10
concept_erasure/alf_qleace.py
Outdated
self.x_dim, device=self.global_mean_x.device, dtype=self.global_mean_x.dtype | ||
) | ||
|
||
# Compute QLEACE component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compute ALF-Q components
concept_erasure/alf_qleace.py
Outdated
|
||
# Select the principal direction associated with the singular value | ||
U, S, Vh = svds[z_idx] | ||
principal_direction = U[:, 0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use squeeze()
concept_erasure/alf_qleace.py
Outdated
svds: list[tuple[Tensor, Tensor, Tensor]] = [ | ||
torch.svd_lowrank(sigma_xx_z_diffs[i], q=1) for i in range(self.z_dim) | ||
] | ||
spectral_norms = torch.stack([svd[1][0] for svd in svds]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use squeeze()
No description provided.