diffusion_models.models.SimpleUnet

Module Contents

class Block(in_ch, out_ch, time_emb_dim, up=False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

time_mlp[source]
conv2[source]
bnorm1[source]
bnorm2[source]
relu[source]
forward(x, t)[source]
class SinusoidalPositionEmbeddings(dim)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

dim[source]
forward(time)[source]
class SimpleUnet(diffuser, image_channels)[source]

A Simplified variant of the Unet architecture used in DDPM.

Parameters:
  • diffuser (BaseDiffuser) – A gaussian diffuser.

  • image_channels (int) – The number of image channels.

time_mlp[source]
conv0[source]
downs[source]
ups[source]
output[source]
forward(x, timestep, labels=None)[source]

Forward pass of the diffusion model.

The forward pass of the diffusion model, predicting the noise at a single step.

Parameters:
  • x (Tensor) – A batch of noisy images.

  • timestep (Tensor) – The timesteps of each image in the batch.

  • labels – Optional labels to be passed when conditioning the diffusion model.

Returns:

A tensor representing the noise predicted for each image.