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

rvae.decode() fails to decode #89

Open
utkarshp1161 opened this issue Jun 11, 2024 · 5 comments
Open

rvae.decode() fails to decode #89

utkarshp1161 opened this issue Jun 11, 2024 · 5 comments

Comments

@utkarshp1161
Copy link

utkarshp1161 commented Jun 11, 2024

Below code expect a 2 dimensional z_mean (like the vanilla vae case)

z_mean, z_std = rvae.encode(norm_patches)
rvae.decode(z_mean)
  • when tried with last two latent variables: rvae.decode(z_mean[:, 1:]) -> the decoded patches look very different

Tried a hacky way to decode following: forward_compute_elbo

z_mean, z_std = rvae.encode(norm_patches)
z1, z2, z3 = z_mean[:,0], z_mean[:, 1:3], z_mean[:, 3:]
x_coord_ = rvae.x_coord.expand(norm_patches.shape[0], *rvae.x_coord.size()).cpu()
phi = torch.tensor(z1) # angle
dx = torch.tensor(z2)  # translation
dx = (dx * rvae.dx_prior).unsqueeze(1)
x_coord_ = utils.transform_coordinates(x_coord_, phi, dx)
decoded_patches = rvae.decoder_net(x_coord_.to("cuda"), torch.tensor(z3).to("cuda"))

It will be useful to have this functionality directly using vae.decode(z_mean)

@ziatdinovmax
Copy link
Collaborator

Hmm... can you please elaborate on the way in which it failed to decode? Did it throw an error?

@utkarshp1161
Copy link
Author

Sure. Here is the link to elaborated error msg.

@ziatdinovmax
Copy link
Collaborator

@utkarshp1161 - Ah OK, I see what you mean. We can re-write the decode method for rvae, based on the snippet you provided earlier. Would you like to give it a try?

@utkarshp1161
Copy link
Author

@ziatdinovmax, sure.

@utkarshp1161
Copy link
Author

Raised a pull request here #90

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