What is a tensor?
A vector is a list (one index), a matrix is a grid (two), a 3-tensor is a cube (three). In diagram notation each index is a leg, and the product rule reads d(TM) = (dT)M + T(dM).
The Cauchy stress tensor maps a face normal to the force on that face: T(eⱼ) = σᵢⱼ eᵢ. Rotate the element and σx′, σy′, τx′y′ all change, yet they stay on one Mohr circle.
Variational Autoencoder by hand ✍️ ~ 11 steps walkthrough below
A VAE learns the structure of your data, the mean and variance of its hidden features, and then generates new data from that structure.
A GAN only learns to fool a discriminator. It can make convincing fakes without ever knowing what the data is really made of. That is the difference, and it is the whole reason VAEs matter.
In 2024 ICLR gave its first ever Test of Time Award to the VAE paper, "Auto-Encoding Variational Bayes" by Diederik Kingma and Max Welling, ten years on.
How does it work?
Goal: encode three inputs into a distribution, sample from it, decode it back, and read every loss gradient off the page.
= 1. Given =
Three training examples X1, X2, X3, copied to the bottom as their own targets. Reconstructing your own input is what puts the "auto", meaning self, in autoencoder.
= 2. Encoder, layer 1 =
Let us multiply the inputs by weights and biases, then apply ReLU, crossing out every negative.
= 3. Mean and standard deviation =
We multiply the features by two more weight sets. The first predicts the means μ of the latent distributions, the second their standard deviations σ.
= 4. A random offset =
Let us sample ε from a standard normal, mean 0 and variance 1, and multiply it by σ. This is a random step away from the mean, scaled by how uncertain each feature is.
= 5. Mean plus offset =
We add the offset back onto μ, and these become the decoder's inputs. Keeping the randomness out in ε is the reparameterization trick: it lets gradients flow straight through the sampling.
= 6. Decoder, layer 1 =
Let us multiply by weights and biases and apply ReLU again. Here -4 is crossed out.
= 7. Decoder, layer 2 =
We multiply once more. The output Y is the decoder's attempt to rebuild X from the sampled distribution.
= 8. Gradient for the mean =
Let us push μ toward 0. A lot of math, the SGVB estimator, collapses the KL gradient to simply μ itself.
= 9. Gradient for the standard deviation =
We want σ to approach 1.
= 10. And its formula =
That same math simplifies the gradient to σ minus 1/σ.
= 11. Reconstruction gradient =
We want the reconstruction Y to match the input X. Mean squared error simplifies its gradient to Y minus X.
Takeaway: the two gradients you just calculated each sit at the heart of a modern method, so one VAE teaches you both. The KL divergence is the penalty RLHF like GRPO uses to keep a fine-tuned model from drifting off its base. The reconstruction loss, plain mean squared error, is exactly what trains a diffusion model to denoise. Draw one VAE by hand and you have quietly learned the core of both.
💾 Save this post!
Great news for RAG developers 🤗
Here's IBM’s new Granite Docling V2 on an old newspaper scan. It extracts the text and shows where each block came from on the original page.
And it runs locally :))
Jensen: "You make an excellent point, sir."
Sen. Kevin Cramer: Thank you.
Jensen: "The fact that the United States relies on rare earths from China or other countries is precisely advantageous for them and disadvantageous for us.
The opposite is equally true, sir.
It is advantageous for the United States that the world builds their economy upon American technology."
Sen. Cramer: Sure.