reoneo97 / vae-playground

Implementation of Variational Autoencoders using Pytorch Lightning
33 stars 1 forks source link

How to extract the latent representation of autoencoder. #1

Closed Mengzhiyaa closed 3 years ago

Mengzhiyaa commented 3 years ago

Hi, I am a beginner in deep learning, and I want to use the latent space generated by the autoencoder to predict the biological meaning in genomic data, but I don't know how to extract it after training. I followed the blog you published in web(https://towardsdatascience.com/beginner-guide-to-variational-autoencoders-vae-with-pytorch-lightning-13dbc559ba4b), and noticed that you create the hidden variable in the forward function, does this is the latent representation?

thx.

reoneo97 commented 3 years ago

Hey,

The blogpost that I wrote uses a Variational Autoencoder which encodes data as a mean and variance vector. If you want to use the same code in the repo you can try using model.reparametrize(model.encode(x)) to get the hidden representation. However I think that for your specific use case it might be better to use a vanilla autoencoder which should be relatively simple to code out using PyTorch linear layers. Good luck!