Problems
Loading...
Step 4 of 5
Training Objective
Medium

Implement the simplified DDPM noise-prediction objective.

Lsimple=1N∑i=1N(ϵi−ϵθ,i)2.L_{\mathrm{simple}} = \frac{1}{N}\sum_{i=1}^{N}\left(\epsilon_i-\epsilon_{\theta,i}\right)^2.

Here, ϵ\epsilon is the Gaussian noise used to construct a noisy training sample, ϵθ\epsilon_\theta is the denoiser's prediction of that noise, and NN is the number of scalar values in the batch. Return the mean squared error as a Python float rounded to six decimals.

Loading visualization...

Examples

Input: epsilon=[[0.5,-0.3],[0.1,-0.8]], epsilon_pred=[[0,0],[0,0]]

Output: 0.2475

Explanation: The result is the mean of the four squared noise-prediction errors.

Input: epsilon=[[0.5,-0.3],[0.1,-0.8]], epsilon_pred=[[0.5,-0.3],[0.1,-0.8]]

Output: 0.0

Input: epsilon=[[1,-1]], epsilon_pred=[[0.8,-0.7]]

Output: 0.065

Hint 1

Subtract epsilon_pred from epsilon before squaring.

Hint 2

Use np.mean over the complete squared-error array.

Requirements

  • Use NumPy.
  • Compute the squared difference between epsilon and epsilon_pred elementwise.
  • Average across every batch and feature dimension.
  • Return one nonnegative Python float rounded to six decimals.

Constraints

  • epsilon and epsilon_pred are equally shaped, nonempty nested lists of real numbers.
  • Calculations use NumPy float64.