Variational Autoencoders (VAEs) are generative models that learn a smooth,
probabilistic latent space, allowing them not only to compress and reconstruct data but
also to generate entirely new, realistic samples. VAEs capture the underlying structure
of a dataset and produce outputs that closely resemble the original data.
Learns a continuous latent representation
Enables controlled and meaningful data generation
Widely used in image synthesis, anomaly detection, and representation learning
Architecture of Variational Autoencoder
just compressing and reconstructing it. It has three main parts:
1. Encoder (Understanding the Input)
The encoder takes input data like images or text and learns its key features. Instead of
outputting one fixed value, it produces two vectors for each feature:
Mean (μ): A central value representing the data.
Standard Deviation (σ): It is a measure of how much the values can vary.
These two values define a range of possibilities instead of a single number.
2. Latent Space (Adding Some Randomness)
Instead of encoding the input VAE is a special kind of autoencoder that can generate
new data instead of as one fixed point it pick a random point within the range given
by the mean and standard deviation. This randomness lets the model create slightly
different versions of data which is useful for generating new, realistic samples.
3. Decoder (Reconstructing or Creating New Data)
The decoder takes the random sample from the latent space and tries to reconstruct the
original input. Since the encoder gives a range, the decoder can produce new data that
is similar but not identical to what it has seen.
Mathematics behind Variational Autoencoder
Variational autoencoder uses KL-divergence as its loss function the goal of this is to
minimize the difference between a supposed distribution and original distribution of
dataset.
Suppose we have a distribution z and we want to generate the observation x from it.
In other words we want to calculate p(z∣x) We can do it by following way: