Implementing a variational autoencoder
Some of the most modern and complex use cases of autoencoders are Variational Autoencoders (VAEs). They differ from the rest of the autoencoders in that, instead of learning an arbitrary function, they learn a probability distribution of the input images. We can then sample this distribution to produce new, unseen data points.
A VAE is, in fact, a generative model, and in this recipe, we'll implement one.
Getting ready
We don't need any special preparation for this recipe, so let's get started right away!
How to do it…
Follow these steps to learn how to implement and train a VAE:
- Import the necessary packages:
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from tensorflow.keras import Model from tensorflow.keras import backend as K from tensorflow.keras.datasets import fashion_mnist from tensorflow.keras.layers import * from tensorflow.keras.losses import mse from tensorflow...