Implement the simplified DDPM noise-prediction objective.
Lsimple=N1i=1∑N(ϵi−ϵθ,i)2.Here, ϵ is the Gaussian noise used to construct a noisy training sample, ϵθ is the denoiser's prediction of that noise, and N is the number of scalar values in the batch. Return the mean squared error as a Python float rounded to six decimals.
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.
All steps in DDPM
- Forward Diffusion
- Reverse Process
- Noise Schedule
- Training Objective
- Sampling Algorithm
Accepts: array
Accepts: array
Training Objective
Implement the simplified DDPM noise-prediction objective.
Lsimple=N1i=1∑N(ϵi−ϵθ,i)2.Here, ϵ is the Gaussian noise used to construct a noisy training sample, ϵθ is the denoiser's prediction of that noise, and N is the number of scalar values in the batch. Return the mean squared error as a Python float rounded to six decimals.
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.
All steps in DDPM
- Forward Diffusion
- Reverse Process
- Noise Schedule
- Training Objective
- Sampling Algorithm
Accepts: array
Accepts: array