liveBook · Manning

Timestep embedding

As explained in Build a Text-to-Image Generator (from Scratch)

A time embedding is a learned vector or tensor representation of a diffusion time step supplied to a denoising network.

A timestep embedding converts the scalar diffusion step into a vector or tensor that tells a denoising network how much noise the current image contains. In a learned implementation, an embedding block maps the normalized step through two linear layers with a GELU activation, producing representations sized for different U-Net stages. This differs from the fixed sine-and-cosine timestep encoding used in a latent-diffusion implementation. section 6.2.1 section 9.3.2

Trace a timestep embedding through a conditional denoising U-Net:

  • Project the one-dimensional timestep into separate channel widths, such as 512 and 256 dimensions. section 6.2.1
  • Inject the timestep tensors into the U-Net's expansive path alongside label embeddings, so decoder blocks receive both noise-level and class information. section 6.3.1

Embedding timestep 25

Instantiate EmbedLayer(1, 512) and EmbedLayer(1, 256), pass the normalized timestep 25/1000 to both, and reshape the outputs to (1, 512, 1, 1) and (1, 256, 1, 1).

How Build a Text-to-Image Generator (from Scratch) covers it

How deep it goes
Explains projection layers, activation, normalization, reshaping, and decoder injection, but does not derive diffusion schedules.
Examples
Uses timestep 25 with 512- and 256-channel outputs, then applies timestep embeddings during latent reverse diffusion across 50 inference steps.
What it assumes
Assumes diffusion timesteps and noisy images, while teaching how to transform a scalar timestep into network-ready tensors.
What you can do after
Build it from scratch in PyTorch and pass timestep tensors into conditional denoising U-Net stages.
How it connects
Connects timestep embeddings to diffusion models, denoising U-Nets, noise schedulers, label embeddings, and classifier-free guidance.

Also explained in

Compare how 2 books explain timestep embedding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Text-to-Image Generator (from Scratch). The section links point to the parts of the book it draws on.