ScoreSdeVeScheduler¶
ScoreSdeVeScheduler
is a variance exploding stochastic differential equation (SDE) scheduler. It was introduced in the Score-Based Generative Modeling through Stochastic Differential Equations paper by Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, Ben Poole.
The abstract from the paper is:
Creating noise from data is easy; creating data from noise is generative modeling. We present a stochastic differential equation (SDE) that smoothly transforms a complex data distribution to a known prior distribution by slowly injecting noise, and a corresponding reverse-time SDE that transforms the prior distribution back into the data distribution by slowly removing the noise. Crucially, the reverse-time SDE depends only on the time-dependent gradient field (\aka, score) of the perturbed data distribution. By leveraging advances in score-based generative modeling, we can accurately estimate these scores with neural networks, and use numerical SDE solvers to generate samples. We show that this framework encapsulates previous approaches in score-based generative modeling and diffusion probabilistic modeling, allowing for new sampling procedures and new modeling capabilities. In particular, we introduce a predictor-corrector framework to correct errors in the evolution of the discretized reverse-time SDE. We also derive an equivalent neural ODE that samples from the same distribution as the SDE, but additionally enables exact likelihood computation, and improved sampling efficiency. In addition, we provide a new way to solve inverse problems with score-based models, as demonstrated with experiments on class-conditional generation, image inpainting, and colorization. Combined with multiple architectural improvements, we achieve record-breaking performance for unconditional image generation on CIFAR-10 with an Inception score of 9.89 and FID of 2.20, a competitive likelihood of 2.99 bits/dim, and demonstrate high fidelity generation of 1024 x 1024 images for the first time from a score-based generative model.
mindone.diffusers.ScoreSdeVeScheduler
¶
Bases: SchedulerMixin
, ConfigMixin
ScoreSdeVeScheduler
is a variance exploding stochastic differential equation (SDE) scheduler.
This model inherits from [SchedulerMixin
] and [ConfigMixin
]. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.
PARAMETER | DESCRIPTION |
---|---|
num_train_timesteps |
The number of diffusion steps to train the model.
TYPE:
|
snr |
A coefficient weighting the step from the
TYPE:
|
sigma_min |
The initial noise scale for the sigma sequence in the sampling procedure. The minimum sigma should mirror the distribution of the data.
TYPE:
|
sigma_max |
The maximum value used for the range of continuous timesteps passed into the model.
TYPE:
|
sampling_eps |
The end value of sampling where timesteps decrease progressively from 1 to epsilon.
TYPE:
|
correct_steps |
The number of correction steps performed on a produced sample.
TYPE:
|
Source code in mindone/diffusers/schedulers/scheduling_sde_ve.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
mindone.diffusers.ScoreSdeVeScheduler.scale_model_input(sample, timestep=None)
¶
Ensures interchangeability with schedulers that need to scale the denoising model input depending on the current timestep.
PARAMETER | DESCRIPTION |
---|---|
sample |
The input sample.
TYPE:
|
timestep |
The current timestep in the diffusion chain.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
|
Source code in mindone/diffusers/schedulers/scheduling_sde_ve.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
mindone.diffusers.ScoreSdeVeScheduler.set_sigmas(num_inference_steps, sigma_min=None, sigma_max=None, sampling_eps=None)
¶
Sets the noise scales used for the diffusion chain (to be run before inference). The sigmas control the weight
of the drift
and diffusion
components of the sample update.
PARAMETER | DESCRIPTION |
---|---|
num_inference_steps |
The number of diffusion steps used when generating samples with a pre-trained model.
TYPE:
|
sigma_min |
The initial noise scale value (overrides value given during scheduler instantiation).
TYPE:
|
sigma_max |
The final noise scale value (overrides value given during scheduler instantiation).
TYPE:
|
sampling_eps |
The final timestep value (overrides value given during scheduler instantiation).
TYPE:
|
Source code in mindone/diffusers/schedulers/scheduling_sde_ve.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
mindone.diffusers.ScoreSdeVeScheduler.set_timesteps(num_inference_steps, sampling_eps=None)
¶
Sets the continuous timesteps used for the diffusion chain (to be run before inference).
PARAMETER | DESCRIPTION |
---|---|
num_inference_steps |
The number of diffusion steps used when generating samples with a pre-trained model.
TYPE:
|
sampling_eps |
The final timestep value (overrides value given during scheduler instantiation).
TYPE:
|
Source code in mindone/diffusers/schedulers/scheduling_sde_ve.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
mindone.diffusers.ScoreSdeVeScheduler.step_correct(model_output, sample, generator=None, return_dict=False)
¶
Correct the predicted sample based on the model_output
of the network. This is often run repeatedly after
making the prediction for the previous timestep.
PARAMETER | DESCRIPTION |
---|---|
model_output |
The direct output from learned diffusion model.
TYPE:
|
sample |
A current instance of a sample created by the diffusion process.
TYPE:
|
generator |
A random number generator.
TYPE:
|
return_dict |
Whether or not to return a [
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[SchedulerOutput, Tuple]
|
[ |
Source code in mindone/diffusers/schedulers/scheduling_sde_ve.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
mindone.diffusers.ScoreSdeVeScheduler.step_pred(model_output, timestep, sample, generator=None, return_dict=False)
¶
Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion process from the learned model outputs (most often the predicted noise).
PARAMETER | DESCRIPTION |
---|---|
model_output |
The direct output from learned diffusion model.
TYPE:
|
timestep |
The current discrete timestep in the diffusion chain.
TYPE:
|
sample |
A current instance of a sample created by the diffusion process.
TYPE:
|
generator |
A random number generator.
TYPE:
|
return_dict |
Whether or not to return a [
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[SdeVeOutput, Tuple]
|
[ |
Source code in mindone/diffusers/schedulers/scheduling_sde_ve.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
mindone.diffusers.schedulers.scheduling_sde_ve.SdeVeOutput
dataclass
¶
Bases: BaseOutput
Output class for the scheduler's step
function output.
PARAMETER | DESCRIPTION |
---|---|
prev_sample |
Computed sample
TYPE:
|
prev_sample_mean |
Mean averaged
TYPE:
|
Source code in mindone/diffusers/schedulers/scheduling_sde_ve.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|