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

[WIP] Add label-free qleace #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[WIP] Add label-free qleace #16

wants to merge 2 commits into from

Conversation

luciaquirke
Copy link
Contributor

No description provided.

# 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)
Copy link
Contributor Author

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

self.x_dim, device=self.global_mean_x.device, dtype=self.global_mean_x.dtype
)

# Compute QLEACE component
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compute ALF-Q components


# Select the principal direction associated with the singular value
U, S, Vh = svds[z_idx]
principal_direction = U[:, 0]
Copy link
Contributor Author

@luciaquirke luciaquirke Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use squeeze()

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])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use squeeze()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant