Skip to content

fix: improve vae stability by controlling the minimum std that can be learned #192

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

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

Conversation

PabloNA97
Copy link
Contributor

For some datasets I obtained the following error:

VAE training failed. Error message: Expected parameter scale (Tensor of shape (128, 2)) of distribution Normal(loc: torch.Size([128, 2]), scale: torch.Size([128, 2])) to satisfy the constraint GreaterThan(lower_bound=0.0), but found invalid values:
tensor([[3.5159e-08, 2.5230e-08],
        [1.7620e-23, 3.2989e-25],
        [6.6246e-12, 2.3463e-10],
        [9.5324e-04, 3.7065e-03],
...

This is related to the scale parameter of torch.distributions.Normal being too small. To improve numerical stability during training I think it's a common practice to limit the minimum std that can be learned through torch.clamp().

A minimum of -15 in the log variance would be a minimum value of 1e-15 in the std.

With this modification the instability is gone :)

@PabloNA97
Copy link
Contributor Author

I forgot to remove the eps (1e+8) that I was adding to the std. This was the first approach but I think torch.clamp should work better.

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