The deterministic DDIM update (eta = 0) is the workhorse of fast sampling. Implement one step given x_t, the predicted noise, and the two alpha-bar values.
Background
With eta = 0 there is no injected noise, so the update is
Compute the predicted clean sample x^0 using the formula x^0=αˉtxt−1−αˉtε^. With αˉt=0.5, the scaling factors are 1−0.5=0.5≈0.7071 and 0.5≈0.7071.
For the first dimension, substitute xt=1.4142 and ε^=1.0: x^0,1=0.70711.4142−(0.7071⋅1.0)=0.70710.7071=1.0.
For the second dimension, substitute xt=0.0 and ε^=−1.0: x^0,2=0.70710.0−(0.7071⋅−1.0)=0.70710.7071=1.0. Thus, x^0=[1.0,1.0].
Compute the next state xt′ using xt′=αˉt′x^0+1−αˉt′ε^. Since αˉt′=1.0, the coefficients are 1.0=1.0 and 1−1.0=0.0.
Apply the coefficients to the vectors: xt′=1.0⋅[1.0,1.0]+0.0⋅[1.0,−1.0]=[1.0,1.0].
The final output is [1.0, 1.0]
Constraints
len(x_t) == len(eps); alpha-bar values in (0, 1].
alpha_bar_prev = 1.0 yields exactly x0_hat (the direction term vanishes).
DDPM (Denoising Diffusion Probabilistic Models) and DDIM (Denoising Diffusion Implicit Models) are two frameworks for sampling from a learned noise distribution. In DDPM, each reverse step is stochastic: you predict the noise ε^, estimate the clean signal x^0, and then add fresh Gaussian noise to move to xt−1. DDIM generalizes this by introducing a parameter η∈[0,1] that controls how much stochasticity remains. When η=0, the process becomes deterministic: the same predicted noise ε^ is reused as the "direction" toward the noisy sample, and no new random noise is injected.
The forward process defines αˉt=∏s=1tαs, where αs=1−βs. The noisy sample is xt=αˉtx0+1−αˉtε. The model predicts ε^ from xt. From this prediction you can recover an estimate of the clean signal:
x^0=αˉtxt−1−αˉtε^
For the deterministic DDIM step, you then reconstruct xt′ (where t′<t) by blending x^0 and ε^ using the previous alpha-bar value:
xt′=αˉt′x^0+1−αˉt′ε^
This is a linear combination, so the operation is element-wise over the feature dimension D.
2. Algorithm Approach
The problem reduces to two vectorized (or element-wise) arithmetic operations:
Predict x^0: For each dimension i, compute x^0[i]=αˉtxt[i]−1−αˉt⋅ε^[i].
Reconstruct xt′: For each dimension i, compute xt′[i]=αˉt′⋅x^0[i]+1−αˉt′⋅ε^[i].
No loops over timesteps are needed—this is a single-step update. The key insight is that both αˉt and 1−αˉt are scalars shared across all dimensions, so you compute them once and apply them element-wise.
3. Step-by-Step Strategy
PRO
Continue the full explanation
You're reading the free preview. Unlock the complete walkthrough, the code editor, test runner and reference solution with Premium.
PRO
Editor locked
The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.