From the course: Programming Generative AI: From Variational Autoencoders to Stable Diffusion with PyTorch and Hugging Face

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Transforming an autoencoder into a VAE

Transforming an autoencoder into a VAE

- [Instructor] Now that we saw vanilla auto encoders in PyTorch, as well as how to represent convolutional layers in PyTorch, I wanted to put all these pieces together to build the final demonstration of this lesson, a convolutional variational auto encoder in PyTorch! Now, I'm going to start with the same auto encoder code that we saw before with simple linear layers and slowly morph this into a convolutional variational auto encoder, and then train that on the same fashion MNIST dataset. So, to turn this simple auto encoder into a convolutional auto encoder, not variational yet, we can simply replace these linear layers in our sequential module with some convolutional 2D layers. And these layers here are the same as what we saw before. We have a number of in channels. So since our input data is grayscale, we really only have one channel in. And the out channels are the number of feature maps we want to generate. Since this is an internal convolutional layer, we can really set this…

Contents