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

How AdaIN works? #5

Open
mkstmyk opened this issue Dec 9, 2022 · 0 comments
Open

How AdaIN works? #5

mkstmyk opened this issue Dec 9, 2022 · 0 comments

Comments

@mkstmyk
Copy link

mkstmyk commented Dec 9, 2022

Hi again! Please allow me to ask a newbie question.
The way of calculating the mean and variance in AdaIN is a bit tricky for me.
It seems to be just using nn.Linear to compute them at once and split it into gamma(variance) and beta(mean).
Will it lean to compute mean and variance during the training?
If so, where can I find the process to guarantee it?
Thank you again in advance.

class AdaIN(nn.Module):

def __init__(self, style_dim, num_features):
    super(AdaIN, self).__init__()
    self.norm = nn.InstanceNorm2d(num_features, affine=False)
    self.fc = nn.Linear(style_dim, num_features * 2)

def forward(self, x, s):
    h = self.fc(s)
    h = h.view(h.size(0), h.size(1), 1, 1)
    gamma, beta = torch.chunk(h, chunks=2, dim=1)
    return (1 + gamma) * self.norm(x) + beta
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

1 participant