liveBook · Manning

Mean absolute error

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

Mean absolute error, also called L1 loss, measures the average absolute difference between predicted numerical values and their target values.

Mean absolute error (MAE), also called L1 loss, measures the average absolute difference between predicted numerical values and their targets. In diffusion training, it measures the difference between noise predicted by a denoising U-Net and the noise actually injected into images. section 5.3.1 section 5.4.3

A training step uses MAE in this sequence:

  • Add randomly selected amounts of noise to clean images. section 5.3.1
  • Pass the noisy images and their time steps to the denoising U-Net. section 5.3.1
  • Compare predicted noise with ground-truth noise using PyTorch's l1_loss. section 5.4.3 section 7.3.2
  • Backpropagate the loss and update model parameters to minimize it. section 5.4.3

Diffusion-model training

For each noisy clothing or flower image, the model predicts the injected noise. MAE supplies the scalar training signal used to improve those predictions across batches and epochs. section 5.3.1 section 7.3.2

Figure 5.8 Steps to train a denoising U-Net model to remove noise from images

Trace the six-stage loop from clean images and noise injection through prediction, MAE calculation, and parameter updates. section 5.3.1

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

How deep it goes
Explains the training role and PyTorch implementation, but does not derive the metric mathematically.
Examples
Uses noisy clothing-item and flower images, predicted noise tensors, and epoch-by-epoch generated-image checks.
What it assumes
Assumes noisy-image generation, U-Net prediction, ground-truth noise, and gradient-based parameter updates.
What you can do after
Apply it via PyTorch to optimize a denoising U-Net during diffusion-model training.
How it connects
Connects MAE to diffusion models, denoising U-Nets, AdamW, and learning-rate scheduling.

Also explained in

Compare how 10 books explain mean absolute error →

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.