ch.uint8).numpy()[0])

The training objective of the model is to predict the noise added to the image. The loss at this step can be calculated by:


	Copied
>>> import torch.nn.functional as F

>>> noise_pred = model(noisy_image, timesteps).sample
>>> loss = F.mse_loss(noise_pred, noise)

Train the model
	
By now, you have most of the pieces to start training the model and all that’s left is putting everything together.
First, you’ll need an op