lesson 3 / 6·Reparameterisation trick15 min · Bloom's apply

Reparameterisation trick

objective Trace gradients through sampling

md[1]

3 · Reparameterisation trick

Instead of sampling `z ~ N(μ, σ²)` directly (which blocks gradients), we reparameterise as `z = μ + σ · ε` where `ε ~ N(0, I)`. Kingma & Welling 2014 showed this makes the sampling differentiable w.r.t. `μ` and `σ`.

In [7][2]
python
import torch

def reparameterise(mu, log_var):
    sigma = torch.exp(0.5 * log_var)
    eps = torch.randn_like(sigma)
    return mu + sigma * eps

mu = torch.zeros(1, 32)
logvar = torch.zeros(1, 32)
z = reparameterise(mu, logvar)
print(z.shape, z.mean().item())
out [7]
torch.Size([1, 32]) -0.018
viz[3]
Sampled z points in latent space (2-d projection, 200 samples).
ex[4]
exercise
Task — change `mu` to a non-zero tensor and `logvar` to `-2.0`. What happens to the variance of `z`? Run it, then answer the quiz below.
?[5]
check your understanding

What is the role of `ε` in the reparameterisation trick?

sh[6]
$ python train.py --epochs 3 --lr 1e-3
Epoch 1/3 · loss 184.2
Epoch 2/3 · loss 168.7
Epoch 3/3 · loss 156.1
Checkpoint → ./runs/vae_mnist.pt

Tutorial StudioAI Tutorial and How-To Content Generation

BeforeTomorrow Tutorial Studio generates step-by-step tutorials, how-to guides, and instructional content. AI handles progressive complexity, visual instruction design, and learning path optimization.

How does BeforeTomorrow Tutorial Studio work?

Tutorial Studiouses BeforeTomorrow's domain engineering approach: rather than a generic AI prompt, it deploys specialized agents trained in the business communication and strategy domain. When you submit a brief, Claude Opus 4.6 handles creative judgment while Sonnet 4.6 manages intelligence extraction — together producing professional output tailored to your specific requirements and industry context.

Unlike generic document generators, every Tutorial Studio output is uniquely generated from scratch — adapting to your industry (across 140+ supported industries), audience, and specific goals. No two outputs are identical because the AI composes each piece individually rather than filling a template.

Tutorial Studio at a glance

  • Category: Business & Professional
  • AI: Claude Opus 4.6 + Sonnet 4.6
  • Platform: 48 studios total on BeforeTomorrow
  • Industries: 140+ with domain-specific knowledge
  • Pricing: Pay-per-generation from $3
  • Output: Unique per generation (no templates)
  • Data: EU residency (AWS Bedrock)
  • Rights: Full commercial usage included
  • Related: Course Studio, Documentation Studio, Knowledge Base Studio, Blog Studio
  • Subscription: Not required

Frequently asked questions about Tutorial Studio

What instructional format?

Step-by-step guides with progressive complexity, visual instruction callouts, prerequisites, and checkpoint assessments.

Does it handle different skill levels?

Yes. AI adapts explanation depth, terminology, and assumed knowledge based on beginner, intermediate, or advanced audience specification.

Last updated: June 2026