BigVGAN icon indicating copy to clipboard operation
BigVGAN copied to clipboard

Alphas are not trainable?

Open PiotrDabkowski opened this issue 2 years ago • 4 comments

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

PiotrDabkowski avatar Jul 17 '22 16:07 PiotrDabkowski

Thank you...

I have mis-implemented this parameter...

I'll fix it right now.

Thanks again

sh-lee-prml avatar Jul 18 '22 01:07 sh-lee-prml

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👍

sh-lee-prml avatar Jul 18 '22 01:07 sh-lee-prml

@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?

HaiFengZeng avatar Nov 08 '22 01:11 HaiFengZeng

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)

sh-lee-prml avatar Nov 08 '22 05:11 sh-lee-prml