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

Alphas are not trainable? #10

Open
PiotrDabkowski opened this issue Jul 17, 2022 · 4 comments
Open

Alphas are not trainable? #10

PiotrDabkowski opened this issue Jul 17, 2022 · 4 comments

Comments

@PiotrDabkowski
Copy link

I have noticed that alphas is not a ModuleList, but rather a list of parameters, this causes them to be not trainable.

Example: self.alpha1 = [nn.Parameter(torch.ones(1, channels, 1).to(rank)) for i in range(len(self.convs1))]
Is this expected?

image

@sh-lee-prml
Copy link
Owner

Thank you...

I have mis-implemented this parameter...

I'll fix it right now.

Thanks again

@sh-lee-prml
Copy link
Owner

self.alpha1 = nn.ParameterList([nn.Parameter(torch.ones(1, channels, 1)) for i in range(len(self.convs1))])

I changed alphas to ParameterList

https://github.com/sh-lee-prml/BigVGAN/blob/main/models_bigvgan.py#L51
https://github.com/sh-lee-prml/BigVGAN/blob/main/models_bigvgan.py#L52
https://github.com/sh-lee-prml/BigVGAN/blob/main/models_bigvgan.py#L100
https://github.com/sh-lee-prml/BigVGAN/blob/main/models_bigvgan.py#L102
https://github.com/sh-lee-prml/BigVGAN/blob/main/models_bigvgan.py#L108

image

Now, alpha is trainable 😢

Thank you again👍

@HaiFengZeng
Copy link

@sh-lee-prml alpha need to be greater than 0 as a frequency parameter? maybe add a torch.exp(alpha) to make sure it positive?

@sh-lee-prml
Copy link
Owner

sh-lee-prml commented Nov 8, 2022

Hi @HaiFengZeng

The official code of snake1d initializes it greater than 0 by abs()

a = torch.zeros_like(x[0]).normal_(mean=0,std=50).abs()

But, I think it does not need to be greater than 0. The negative alpha value just has an inverted phase, and we used the squared value as below

x = (x + (torch.sin(self.a * x) ** 2) / self.a)

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

No branches or pull requests

3 participants