DMD2Model<T>

Models & Types · AiDotNet.Diffusion.FastGeneration

Distribution Matching Distillation v2 (DMD2) for single-step high-fidelity generation.

Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → DMD2Model<T>

For Beginners

DMD2 trains a student model to produce images that match the distribution of a teacher (full diffusion model) in a single step. It’s like having a talented student who can paint a complete picture in one stroke, trained by watching a master who paints in many careful strokes.

How It Works

DMD2 improves upon DMD by introducing a regression loss alongside the distribution matching loss, eliminating the need for an expensive GAN discriminator. Achieves state-of-the-art single-step FID on ImageNet while being simpler to train than ADD.

Reference: Yin et al., “Improved Distribution Matching Distillation for Fast Image Synthesis”, NeurIPS 2024

Example

// Create a DMD2 model for single-step high-fidelity generation
var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 1 };
var noise = Tensor<float>.CreateRandom(new[] { 1, 4, 64, 64 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new DMD2Model<float>(options: options))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
DMD2Model(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) Initializes a new DMD2 model.

Properties

Property Summary
IConditioningModule<T> Conditioner { get; }
INoisePredictor<T> NoisePredictor { get; }
IVAEModel<T> VAE { get; }
int LatentChannels { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()