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

Question on how to reconstruct images #7

Closed
MrHuff opened this issue May 4, 2019 · 6 comments
Closed

Question on how to reconstruct images #7

MrHuff opened this issue May 4, 2019 · 6 comments

Comments

@MrHuff
Copy link

MrHuff commented May 4, 2019

Hi!

Thanks a lot for this repo, it's really great! I am wondering how to reconstruct images, since the current reverse method seems to take a list of images with different sizes.

I tried writing a method:

    def reverse_data(self,z):
        for i, block in enumerate(self.blocks[::-1]):
            if i == 0:
                eps = torch.randn_like(z)
                input = block.reverse(z,eps)

            else:
                eps = torch.zeros_like(input)
                input = block.reverse(input,eps)

        return input

But I am unsure whether this is correct. I would appreciate any help!

Thank you!

@rosinality
Copy link
Owner

First you need to gather zs from blocks. Then you can reverse using these zs, but you will need to skip sampling (reparameterization) using prior. You can may refer to this: 4beed5d.

@MrHuff
Copy link
Author

MrHuff commented May 4, 2019

Hi I just tried it out and it works perfectly now! Thank you very much your help!

@MrHuff MrHuff closed this as completed May 4, 2019
@koriavinash1
Copy link

koriavinash1 commented Nov 29, 2021

for reconstruction do we need to normalize zs (obtained during the forward pass)?

Currently, I'm training glow on mnist with affine coupling, during the forward pass zs blows up to 100k sometimes, due to which reconstructions are Nan always. Let me if normalization is required or if I'm missing any other step during reconstruction.

Thank you!

@rosinality
Copy link
Owner

rosinality commented Nov 29, 2021

@koriavinash1 No, you don't need a normalization. It should be enough to give zs from forward to reverse with reconstruct=True.

@koriavinash1
Copy link

@rosinality thanks for the quick response, do you have any idea on how to resolve the NaN issue?

@rosinality
Copy link
Owner

@koriavinash1 You can try to reduce --n_flow and --n_block to make the model more stable.

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