Interactive Monograph · Generative Machine Learning

Diffusion models, in plain words

A neural network that learns to turn noise into data by mastering one humble skill: removing a little noise at a time. Start from static, denoise step by step, and a sample of something realistic appears. This monograph builds the idea from scratch, with a model that trains live in your browser, then puts it to work generating and guarding automotive signals.

01 / The one idea

Learn to undo noise, then start from noise

Imagine slowly stirring a drop of ink into water until the picture it once formed is gone, just uniform gray. That destruction is easy and needs no intelligence. The hard and useful direction is the reverse: starting from gray and running the stirring backward until a picture reassembles. A diffusion model learns exactly that reverse step.

Training has two halves. In the forward process we take real data and corrupt it with Gaussian noise in many small steps, all the way to pure static. This is fixed and hand-defined, no learning involved. In the reverse process a neural network is trained to undo one small step of that corruption: given a noisy example, predict the noise that was added. Chain those learned removals together and you can walk from random static back to a brand-new, realistic sample.

In a sentence

A diffusion model is trained to remove a little noise at a time. Generation is just doing that repeatedly, starting from pure noise, until a fresh sample emerges.

Why bother with tiny steps instead of one big leap? Because each small denoising is an easy problem the network can learn well, and hundreds of easy steps compose into a very hard one: conjuring structured data from nothing. This is what powers modern image and audio generators, and, as the later sections show, what can synthesize rare sensor signals and flag abnormal ones in a vehicle.

02 / The forward process

Dissolving data into static

The forward process is a fixed recipe. At each step it shrinks the data slightly and adds a pinch of Gaussian noise. A schedule of numbers, written āḷ (a-bar at step t), tracks how much of the original signal survives: it starts near 1 (all signal) and slides to 0 (all noise). A single formula jumps straight to any step:

xḷ = √āḷ · x₀  +  √(1 – āḷ) · ε
x₀ = clean data · ε = random Gaussian noise · āḷ = surviving signal fraction

Drag the slider to run it on a real two-dimensional dataset, a spiral. As the step rises the spiral loses its shape and melts into a featureless blob of noise. That end state, pure Gaussian static, is exactly where generation will later begin.

step 0 / 40
The forward process is not learned. It is a fixed schedule of shrink-and-add-noise. Its only job is to define a smooth path from real data to pure noise, so the network has a well-posed sequence of small steps to learn to reverse.
03 / Reverse and training

Teaching the network to denoise

Here is the whole training loop. Take a clean example, jump it to a random noise level with the formula above, and hand the noisy result to the network along with which step it came from. The network's job is to predict the noise that was added. Compare its guess to the true noise, and nudge its weights to do better. That is the entire objective.

Loss = ‖ ε – εθ(xḷ, t) ‖²  predicted noise vs actual noise
Training (learn to denoise) clean sample x₀ add noise to step tget xḷ and true ε networkpredict εθ(xḷ,t) compare to true εupdate weights Sampling (generate) pure noise xₜ network removes alittle noise: xḷ → xḷ₋₁ repeat T times new sample x₀
Two loops, one network. Training teaches the network to predict added noise at every level. Sampling reuses that same network in a loop, subtracting a little estimated noise at a time, to walk from static to a fresh sample. No clean data is needed at generation time, only the trained denoiser.
04 / Watch it learn

A diffusion model training in your browser

This is the real thing, a small denoiser built from scratch with no libraries. It learns to turn noise into points that lie on the spiral. Press train and watch the loss fall and the sample cloud snap onto the target shape. Then press sample to animate a fresh cloud of noise being denoised, step by step, into the spiral.

Iterations
0
Loss
Genuine training and sampling. The red points are the model's own samples, generated by denoising random noise with its current weights. Early on they scatter everywhere; as training proceeds they migrate onto the gray target spiral. The sampler uses the DDIM update with light clamping, the same trick production models use to generate in few steps.

Everything you just watched scales up. Replace the two-dimensional spiral with the pixels of an image or the samples of a sensor waveform, swap the small network for a larger one, and the identical loop produces photographs, audio, or the automotive signals in the sections ahead.

05 / Architecture

What the denoiser looks like

The network has one job: read a noisy example and the step number, output the noise to remove. Two design choices matter. First, it must know how noisy the input is, so the step t is turned into a smooth time embedding (a set of sine and cosine features) and fed in alongside the data. Second, its shape follows the data: a U-Net for images, a one-dimensional convolutional or transformer network for signals, and a plain multilayer network for low-dimensional data like our spiral.

noisy input xḷ(pixels / signal / point) step t→ time embedding denoiser network U-Net (images) · 1D conv or transformer (signals) · MLP (low-dim) time embedding injected at each layer predicted noiseεθ(xḷ, t) optional: a condition c (class, operating point, text) can be added to steer what is generated
The denoiser and its inputs. For images the U-Net's downsampling then upsampling path with skip connections is what lets it clean both coarse and fine structure. For the signals in this monograph, a compact network suffices. The dashed note previews conditioning, the key to controllable generation.
06 / Score view and variants

A second viewpoint, and going faster

There is an equivalent and illuminating way to read the network. Predicting the noise is the same as pointing toward higher-probability data, the score, the direction in which the data becomes more likely. Sampling then looks like repeatedly nudging a point uphill toward the data distribution while shaking it a little. This score-based picture is what connects diffusion to a large body of older statistical theory, and it is the basis of the anomaly detector in the inverter section.

Three practical variants matter in the field:

Seeing the score

Because predicting the noise is the same as pointing toward the data, a trained model defines a field of arrows over the whole space, each showing the direction it would push a point to make it more realistic. Here is that field for a model trained on the spiral. Slide the noise level: at low noise the arrows hug the spiral tightly; at high noise they sweep broadly inward from everywhere. Sampling is just following these arrows from a random start.

noise level
The score field. Evaluated from a real trained model. The arrows are the negative of its predicted noise, the direction of increasing data likelihood. This is the geometric heart of both generation and the anomaly detector: healthy points sit where arrows are short and orderly, anomalies where the field is confused.

Steps versus quality

How many denoising steps do you actually need? Fewer steps generate faster but can lose fidelity. Compare the two samplers on the spiral: DDIM is deterministic and stays clean even at few steps, while DDPM injects fresh randomness at every step, visible as extra scatter. The number is the mean distance of the samples to the true spiral, lower is tighter.

20 steps
mean distance to spiral =
The speed-quality dial. For this simple distribution even a handful of steps works well, which is why few-step samplers are so useful. On hard, high-dimensional data the gap widens, and choosing steps and sampler becomes a real engineering tradeoff between latency and fidelity.
07 / The automotive case

Why a vehicle program wants a generative model

Discriminative models answer questions about data you already have. A generative model like a diffusion model produces new data, and for a drivetrain program that unlocks a different set of jobs, especially in health management where the interesting events are rare.

A recurring caution, expanded in the practical notes: a generative model has no built-in respect for physics. Pairing it with the governing equations from the companion monographs is how you keep synthetic signals physically plausible.
08 / Battery

Synthesizing degradation and forecasting charge

A battery's most valuable data is its rarest: cells driven to the edge, unusual fault signatures, deep aging. A diffusion model trained on measured discharge curves learns the shape of normal behavior and can generate new, realistic voltage-under-load traces to enrich a diagnostic dataset. The same forward process from section two applies directly to a real battery signal, watch a discharge trace dissolve into noise.

step 0 / 40
Forward process on a real signal. The dashed teal line is a clean terminal-voltage trace under a pulsed load; the rust line is its noised version at the chosen step. Training a denoiser to reverse this on many such traces yields a generator of synthetic battery behavior.

Turned around and conditioned on the recent past, a diffusion model becomes a probabilistic forecaster: instead of a single predicted state-of-charge or remaining-life number, it samples many plausible futures, and their spread is a calibrated uncertainty band, which is what a battery management system actually needs for a safe margin.

scarce realaging / fault data diffusion modellearns healthy + fault shapes synthetic tracesbalance the dataset forecast samplesSoC / RUL with spread better diagnosticssafer margins
A battery data pipeline. The generator both augments rare-fault training data and, conditioned on history, produces the future distribution that turns a point estimate into a risk-aware one.

A probabilistic forecast, live

This is real. A compact diffusion model was trained on discharge curves, and here it forecasts the rest of a curve from its first half. The solid black line is what has been observed so far; press forecast and the model draws many continuations past the marker, all consistent with the history but spreading apart into the future. That spread is the uncertainty, and the true continuation (dashed teal) should sit inside it.

Forecasting by conditioning on history. The model fills the unknown future while being forced to agree with the observed past at every denoising step. Many samples trace an uncertainty fan, exactly the risk-aware picture a remaining-life or state-of-charge estimate should provide instead of a single fragile number.
rare-fault augmentationprobabilistic SoC / RULsensor imputation
09 / Inverter

Guarding the inverter by what it cannot denoise

The score view from section six gives a clean anomaly detector. Train a diffusion model on healthy inverter telemetry only, junction-temperature traces, current spectra, gate signals. Healthy data is easy for the model to denoise because it lies where the model has seen data. A degrading module produces telemetry the model has never learned, and its denoising error stays stubbornly high. That error is the anomaly score, and it needs no examples of the fault to work.

step 0 / 40
Forward process on a thermal-cycling trace. A junction-temperature waveform under a pulsed load, noised step by step. A model trained to reverse this on healthy traces will reconstruct healthy cycling well and abnormal cycling poorly, and the reconstruction gap is the alarm.
live telemetryTj, current, gate healthy-traineddiffusion model denoising error= anomaly score threshold →flag / derate
Anomaly detection without fault labels. Because the model only ever saw healthy behavior, high reconstruction error is a principled unlike-anything-healthy signal, complementary to the physics-residual detector in the companion vehicle monograph.

Try it: inject a fault

Here the detector is real. A diffusion model trained only on healthy phase current scores a live signal by how badly it can denoise it. Drag the slider to inject a third-harmonic distortion, the signature of a developing fault. The waveform bends, and the anomaly score, which the healthy-trained model cannot help but report, climbs from calm into the alarm zone. No fault example was ever needed to set this up.

0 % 3rd-harmonic
anomaly score = HEALTHY
denoising error against the healthy model
The score is the alarm. A healthy signal lands where the model has seen data, so it denoises easily and scores low. Distortion pushes the signal off the healthy manifold, the denoising error rises, and a simple threshold raises the flag, the same score-field geometry from section six put to work.
10 / Motor

Generating fault signatures for the motor

Diagnostics for a PMSM lean on the shape of its phase currents: a healthy machine gives clean sinusoids, while faults like inter-turn shorts or demagnetization stamp characteristic harmonics onto them. To train a robust classifier you need many examples of each, and the faulty ones are hard to obtain. A diffusion model trained on current signatures can manufacture more.

step 0 / 40
Forward process on a phase-current signature. A current waveform carrying a small harmonic, noised step by step. Learning to reverse this across many signatures is what gives the generator below its command of the signal's shape.

The generator below is real, and it is conditioned on a fault class. One compact diffusion model was trained on labeled phase-current signatures, healthy, demagnetization, and inter-turn short, and its learned weights run right here. Pick a class and it samples a fresh waveform of exactly that type from pure noise. Every trace is newly synthesized, not replayed.

Conditional generation on demand. Healthy traces are clean sinusoids; demagnetization comes out lower in amplitude; the inter-turn short carries the tell-tale third harmonic that makes it look visibly ragged. This is classifier-free guidance in miniature: choose the label, get the signature, and manufacture as many rare-fault examples as a diagnostic classifier needs.

That is the whole augmentation loop. The faulty classes, the ones you can rarely collect from real hardware, are generated to order at whatever mix you want, and a classifier trained on the balanced set becomes sensitive to faults it has seldom, or never, physically seen.

healthy vs fault classesguided generationclassifier augmentation
11 / Practical notes

What to keep in mind

12 / References

Further reading

The foundational and most useful works, in rough order of the ideas above.

  1. Sohl-Dickstein, Weiss, Maheswaranathan, Ganguli. Deep Unsupervised Learning using Nonequilibrium Thermodynamics. ICML, 2015. The original diffusion formulation.
  2. Ho, Jain, Abbeel. Denoising Diffusion Probabilistic Models (DDPM). NeurIPS, 2020. The noise-prediction training used throughout this page.
  3. Song, Ermon. Generative Modeling by Estimating Gradients of the Data Distribution. NeurIPS, 2019. The score-based viewpoint.
  4. Song, Sohl-Dickstein, Kingma, Kumar, Ermon, Poole. Score-Based Generative Modeling through Stochastic Differential Equations. ICLR, 2021. Unifies the two views.
  5. Song, Meng, Ermon. Denoising Diffusion Implicit Models (DDIM). ICLR, 2021. Fast, deterministic sampling, used by the live demo.
  6. Nichol, Dhariwal. Improved Denoising Diffusion Probabilistic Models. ICML, 2021. The cosine noise schedule this page uses.
  7. Ho, Salimans. Classifier-Free Diffusion Guidance. 2022. Controllable, conditional generation.
  8. Rombach, Blattmann, Lorenz, Esser, Ommer. High-Resolution Image Synthesis with Latent Diffusion Models. CVPR, 2022. The latent-space approach behind Stable Diffusion.
  9. Rasul, Seward, Schuster, Vollgraf. TimeGrad: Autoregressive Denoising Diffusion for Multivariate Probabilistic Time Series Forecasting. ICML, 2021. Diffusion for forecasting.
  10. Tashiro, Song, Song, Ermon. CSDI: Conditional Score-based Diffusion Models for Time Series Imputation. NeurIPS, 2021. Filling gaps in sensor data.

Citations are given by author, year, and title for orientation; consult the originals for exact statements.

13 / Glossary

The words to keep

Forward process
The fixed, non-learned schedule that gradually turns data into Gaussian noise.
Reverse process
The learned sequence of small denoising steps that turns noise back into data.
Noise schedule (āḷ)
How much original signal survives at each step, running from near 1 down to 0.
Noise prediction (εθ)
The network's output: an estimate of the noise present in the input at a given step.
Score
The direction toward more probable data; equivalent to the predicted noise up to scaling.
Time embedding
Sine and cosine features of the step number, telling the network how noisy the input is.
DDIM
A deterministic sampler that generates in far fewer steps than the original method.
Classifier-free guidance
A technique to steer generation toward a condition, such as a chosen fault class.
Conditioning
Extra input (class, operating point, history) that controls what gets generated.
This is the third monograph in a series. The first builds physics-informed networks from a spring-mass example; the second applies them to the battery, inverter, and motor.