Class SchedulerConfig<T>
- Namespace
- AiDotNet.NeuralNetworks.Diffusion.Schedulers
- Assembly
- AiDotNet.dll
Configuration options for diffusion model step schedulers.
public sealed class SchedulerConfig<T>
Type Parameters
TThe numeric type used for calculations.
- Inheritance
-
SchedulerConfig<T>
- Inherited Members
Remarks
This configuration class defines all the parameters needed to initialize a step scheduler. These parameters control the noise schedule and behavior of the diffusion process.
For Beginners: This is like a settings panel for the scheduler. You can control:
- How many steps to use (more = higher quality, slower)
- How much noise to start and end with (the beta values)
- What pattern of noise to use (linear, scaled, cosine)
- Whether to clip values to prevent extreme outputs
- What the model is predicting (noise, sample, or velocity)
The default values are research-backed and work well for most cases.
Constructors
SchedulerConfig(int, T, T, BetaSchedule, bool, DiffusionPredictionType)
Initializes a new scheduler configuration.
public SchedulerConfig(int trainTimesteps, T betaStart, T betaEnd, BetaSchedule betaSchedule = BetaSchedule.Linear, bool clipSample = false, DiffusionPredictionType predictionType = DiffusionPredictionType.Epsilon)
Parameters
trainTimestepsintNumber of timesteps for training. Must be greater than 1. Default: 1000.
betaStartTStarting beta value. Must be positive. Default: 0.0001.
betaEndTEnding beta value. Must be greater than betaStart. Default: 0.02.
betaScheduleBetaScheduleThe beta schedule type. Default: Linear.
clipSampleboolWhether to clip samples to [-1, 1]. Default: false.
predictionTypeDiffusionPredictionTypeWhat the model predicts. Default: Epsilon.
Exceptions
- ArgumentOutOfRangeException
Thrown when trainTimesteps is less than 2, or when beta values are invalid.
Properties
BetaEnd
Gets the ending beta value (noise variance at t=T).
public T BetaEnd { get; }
Property Value
- T
Remarks
Beta end is the amount of noise added at the final timestep. It should be larger than beta start to ensure samples become nearly pure noise.
Default: 0.02 for Linear schedule (from DDPM paper)
BetaSchedule
Gets the type of beta schedule to use.
public BetaSchedule BetaSchedule { get; }
Property Value
Remarks
Different schedules provide different noise progression characteristics. Linear is simplest, ScaledLinear is used by Stable Diffusion, SquaredCosine often provides better quality.
Default: Linear (most widely compatible)
BetaStart
Gets the starting beta value (noise variance at t=0).
public T BetaStart { get; }
Property Value
- T
Remarks
Beta start is the amount of noise added at the first timestep. It should be small since early timesteps should preserve most of the signal.
Default: 0.0001 for Linear schedule (from DDPM paper)
ClipSample
Gets whether to clip predicted samples to [-1, 1].
public bool ClipSample { get; }
Property Value
Remarks
Clipping can prevent extreme values that might cause numerical instability, but may reduce output quality if the model is well-trained.
Default: false (let the model produce natural outputs)
PredictionType
Gets the type of prediction the model makes.
public DiffusionPredictionType PredictionType { get; }
Property Value
Remarks
This must match what the diffusion model was trained to predict. Most models use Epsilon (noise) prediction.
Default: Epsilon (most common)
TrainTimesteps
Gets the number of timesteps used during training.
public int TrainTimesteps { get; }
Property Value
Remarks
This is typically 1000 for most diffusion models. More timesteps allow for finer-grained noise schedules but increase training time.
Default: 1000 (standard for DDPM/DDIM)
Methods
CreateDefault()
Creates a default configuration for DDPM-style models.
public static SchedulerConfig<T> CreateDefault()
Returns
- SchedulerConfig<T>
A scheduler configuration with standard DDPM defaults.
Remarks
Uses values from the original DDPM paper: - 1000 training timesteps - Beta start: 0.0001 - Beta end: 0.02 - Linear beta schedule - Epsilon prediction
CreateStableDiffusion()
Creates a configuration optimized for Stable Diffusion-style models.
public static SchedulerConfig<T> CreateStableDiffusion()
Returns
- SchedulerConfig<T>
A scheduler configuration with Stable Diffusion defaults.
Remarks
Uses values from Stable Diffusion: - 1000 training timesteps - Beta start: 0.00085 - Beta end: 0.012 - Scaled linear beta schedule - Epsilon prediction