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

Why there needs flip orperation when calculate the kernel ? #79

Open
123abcgit opened this issue Apr 10, 2023 · 1 comment
Open

Why there needs flip orperation when calculate the kernel ? #79

123abcgit opened this issue Apr 10, 2023 · 1 comment

Comments

@123abcgit
Copy link

Hi, Thanks for sharing the great work, which is very clear. However, I am confused about why there needs flip operation at the end of calc_curr_k function in KernelGAN.py? Looking forward to your reply. Thank you very much.
def calc_curr_k(self):
"""given a generator network, the function calculates the kernel it is imitating"""
delta = torch.Tensor([1.]).unsqueeze(0).unsqueeze(-1).unsqueeze(-1)
for ind, w in enumerate(self.G.parameters()):
curr_k = F.conv2d(delta, w, padding=self.conf.G_kernel_size - 1) if ind == 0 else F.conv2d(curr_k, w)
self.curr_k = curr_k.squeeze().flip([0, 1])

@sefibk
Copy link
Owner

sefibk commented Apr 13, 2023

Hope I understand your question. If so, in order to extract the kernel of G, we pass a delta (1 in the center, 0 everywhere else) through G.
Only then we get the kernel flipped, so we must unflip it.
Try it even with a 1 layer G and you will notice the kernel flipping
Hope that helps

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

2 participants