Recover a signal
01 · Diffusion in latent space
Diffusion in latent space
A model can learn to remove noise gradually to recover structure.
Your turn
Add
Corruption is xₜ=.8×2+.6ε; this scalar calculation does not generate an image.
Understand the calculation, step by step
A diffusion model learns to reverse progressive corruption. Stable Diffusion denoises mostly in latent space before decoding into an image. Our two-mode lab has an analytically known denoiser; it illustrates steps but runs neither a trained U-Net nor Stable Diffusion. This chapter isolates mathematical components.
Add noise
x₀=2 ; ᾱ=0.64 ; xₜ=0.8×2+0.6εCheck my understanding
Keep a thought in my notebook
Read the source and go further
The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.
02 · From text to conditioning
From text to conditioning
Text becomes a numerical representation that guides denoising.
Your turn
Add componentwise
The final representation still has two components; token ID is not multiplied by a vector.
Understand the calculation, step by step
A CLIP tokenizer produces identifiers and an encoder turns the sequence into text representations. The historical demonstration has a limited context length, not a universal diffusion-model limit. Conditioning guides the noise network rather than specifying pixel locations. Compare descriptions differing in one word.
Sum embeddings
token=(x,1), position=(0.1,0.2) ; input=token+positionCheck my understanding
Keep a thought in my notebook
Read the source and go further
The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.
03 · Noise network, time and attention
Noise network, time and attention
The network uses noise, timestep and text to propose a correction.
Your turn
Combine contributions
The weighted sum is 1+.5c. This symmetric kernel avoids a convolution/correlation distinction in this example.
Understand the calculation, step by step
The network predicts noise from noisy latent, timestep and text. A U-Net combines convolutions, resolution changes and cross-level connections; attention can integrate text. Weights are learned from data, not rebuilt per image. A convolution sees a neighbourhood; this exercise isolates filtering rather than simulating a complete U-Net.
Local convolution
neighbourhood=(1,c,3), kernel=(0.25,0.5,0.25) ; response=1+0.5cCheck my understanding
Keep a thought in my notebook
Read the source and go further
The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.
04 · Guidance and trade-offs
Guidance and trade-offs
Guidance adjusts text influence on predicted noise, trading off diversity.
Your turn
Add to unconditional
Guided noise is 1+s. Increasing s does not guarantee better quality.
Understand the calculation, step by step
Guidance combines predictions: ε̂=ε̂empty+s(ε̂text−ε̂empty). At s=0 it uses the empty-text branch; at s=1 the conditioned branch. Larger s can improve text adherence while reducing diversity or introducing artifacts. It acts on predicted noise, not directly on words or final pixels.
Classifier-free guidance
unconditional ε=1 ; text ε=2 ; guided ε=1+s(2−1)Check my understanding
Keep a thought in my notebook
Read the source and go further
The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.
05 · Noise, clean signal and scheduler
Noise, clean signal and scheduler
Estimating noise lets you reconstruct clean signal and prepare the next step.
Your turn
Recover clean scale
Dividing by .8 gives the clean-signal estimate; this is not a full scheduler transition.
Understand the calculation, step by step
Corruption is xₜ=√ᾱₜx₀+√(1−ᾱₜ)ε. Predicted ε̂ gives x̂₀=(xₜ−√(1−ᾱₜ)ε̂)/√ᾱₜ. A scheduler determines the next timestep transition; repeatedly subtracting identical noise is insufficient. DDPM and DDIM can use different transitions. More steps do not automatically fix an inadequate model.
Estimate the clean signal
xₜ=2.2 ; ᾱ=0.64 ; x̂₀=(2.2−0.6ε̂)/0.8Check my understanding
Keep a thought in my notebook
Read the source and go further
The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.
06 · Decode the latent
Decode the latent
A decoder turns a compact internal representation into a more detailed output.
Your turn
A three-component output
Decoding changes dimension. It is not merely pixel resizing.
Understand the calculation, step by step
A learned decoder transforms compact latent into image. The original narrative calls this “upscaling”; mathematically it decodes rather than merely resizing pixels. Our miniature affine function makes latent and output spaces distinct; it represents neither a trained VAE nor its real scaling factors.
Miniature latent decoder
toy decoder D(z)=(z,2z,z−1) ; first component= zCheck my understanding
Keep a thought in my notebook
Read the source and go further
The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.
07 · Compare prompts, seeds and steps
Compare prompts, seeds and steps
To understand a setting, keep other conditions fixed and compare multiple trials.
Your turn
Add to unconditional
Guided noise is 1+s. Increasing s does not guarantee better quality.
Understand the calculation, step by step
A seed fixes initial noise within a given implementation. Compare texts with that seed and other settings fixed, changing one word. Determinism also depends on model and computation. The original uses prepared examples; local notes do not automatically import its images. Robotic actions additionally require demonstrations, constraints and feedback control.
Classifier-free guidance
unconditional ε=1 ; text ε=2 ; guided ε=1+s(2−1)Check my understanding
Keep a thought in my notebook
Read the source and go further
The extended record combines confirmed reading, interaction, correct answer and a note of at least 40 characters. You can continue at any time.
Take this further
atomsh / lab