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 to get the encoded results/embeddings in Outlier Detection? #799

Open
ahmadSum1 opened this issue May 25, 2023 · 2 comments
Open

How to get the encoded results/embeddings in Outlier Detection? #799

ahmadSum1 opened this issue May 25, 2023 · 2 comments
Assignees

Comments

@ahmadSum1
Copy link

I can see from the API reference/examples that I can get the reconstructed image using the calling the od.vae(input_image) function.
Is there a way to get the latent codes/output of the encoder?

@mauicv mauicv self-assigned this May 25, 2023
@mauicv
Copy link
Collaborator

mauicv commented May 25, 2023

Hey @ahmadSum1,
Assuming you've followed the examples here then you can get the latent codes using the following:

z_mean, z_log_var, z = od.vae.encoder(input_image)

Internally we use the reparameterization trick, so z_mean and z_log_var_z parameterize a normal distribution in the latent space, and z is a latent code sampled from this distribution. I'd use z_mean as the latent code as it'll behave deterministically.

Can I ask what your use case is? We've not particularly written the VAE behaviour to make the above easy for users but if there's a good reason to update the docs or code we'd be interested to hear.

@ahmadSum1
Copy link
Author

Hello @mauicv ,
Thanks for the prompt response.
I am trying to plot the PCA/TSNE results on the latent space.
I believe it will be an important feature to provide these built-in or at least document the way to access the submodules.
I.e., histogram plotting of the embeddings, to see how different code size affect the performance.

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