{ "

U-Net model for Denoising Diffusion Probabilistic Models (DDPM)

\n

This is a U-Net based model to predict noise _^_0_^_.

\n

U-Net is a gets it's name from the U shape in the model diagram. It processes a given image by progressively lowering (halving) the feature map resolution and then increasing the resolution. There are pass-through connection at each resolution.

\n

_^_1_^_

\n

This implementation contains a bunch of modifications to original U-Net (residual blocks, multi-head attention) and also adds time-step embeddings _^_2_^_.

\n": "

\u7528\u4e8e\u53bb\u566a\u6269\u6563\u6982\u7387\u6a21\u578b (DDPM) \u7684 U-Net \u6a21\u578b

\n

\u8fd9\u662f\u4e00\u4e2a\u57fa\u4e8e U-Net \u7684\u6a21\u578b\uff0c\u7528\u4e8e\u9884\u6d4b\u566a\u58f0_^_0_^_\u3002

\n

U-Net \u662f\u4ece\u6a21\u578b\u56fe\u4e2d\u7684 U \u5f62\u4e2d\u83b7\u53d6\u5b83\u7684\u540d\u5b57\u3002\u5b83\u901a\u8fc7\u9010\u6b65\u964d\u4f4e\uff08\u51cf\u534a\uff09\u8981\u7d20\u56fe\u5206\u8fa8\u7387\uff0c\u7136\u540e\u63d0\u9ad8\u5206\u8fa8\u7387\u6765\u5904\u7406\u7ed9\u5b9a\u7684\u56fe\u50cf\u3002\u6bcf\u79cd\u5206\u8fa8\u7387\u90fd\u6709\u76f4\u901a\u8fde\u63a5\u3002

\n

_^_1_^_

\n

\u6b64\u5b9e\u73b0\u5305\u542b\u5bf9\u539f\u59cb U-Net\uff08\u6b8b\u5dee\u5757\u3001\u591a\u5934\u6ce8\u610f\uff09\u7684\u5927\u91cf\u4fee\u6539\uff0c\u8fd8\u6dfb\u52a0\u4e86\u65f6\u95f4\u6b65\u957f\u5d4c\u5165_^_2_^_\u3002

\n", "

U-Net

\n": "

U-Net

\n", "

Attention block

\n

This is similar to transformer multi-head attention.

\n": "

\u6ce8\u610f\u529b\u5757

\n

\u8fd9\u7c7b\u4f3c\u4e8e\u53d8\u538b\u5668\u591a\u5934\u7684\u5173\u6ce8\u3002

\n", "

Down block

\n

This combines _^_0_^_ and _^_1_^_. These are used in the first half of U-Net at each resolution.

\n": "

\u5411\u4e0b\u65b9\u5757

\n

\u8fd9\u7ed3\u5408\u4e86_^_0_^_\u548c_^_1_^_.\u8fd9\u4e9b\u5728U-Net\u7684\u524d\u534a\u90e8\u5206\u4ee5\u6bcf\u79cd\u5206\u8fa8\u7387\u4f7f\u7528\u3002

\n", "

Embeddings for _^_0_^_

\n": "

\u5d4c\u5165\u7528\u4e8e_^_0_^_

\n", "

Middle block

\n

It combines a _^_0_^_, _^_1_^_, followed by another _^_2_^_. This block is applied at the lowest resolution of the U-Net.

\n": "

\u4e2d\u95f4\u65b9\u5757

\n

\u5b83\u7ed3\u5408\u4e86_^_0_^_\u3001_^_1_^_\u3001\u540e\u8ddf\u53e6\u4e00\u4e2a_^_2_^_\u3002\u6b64\u5757\u5e94\u7528\u4e8e U-Net \u7684\u6700\u4f4e\u5206\u8fa8\u7387\u3002

\n", "

Residual block

\n

A residual block has two convolution layers with group normalization. Each resolution is processed with two residual blocks.

\n": "

\u5269\u4f59\u65b9\u5757

\n

\u6b8b\u5dee\u5757\u5177\u6709\u4e24\u4e2a\u5177\u6709\u7ec4\u5f52\u4e00\u5316\u7684\u5377\u79ef\u5c42\u3002\u6bcf\u4e2a\u5206\u8fa8\u7387\u90fd\u4f7f\u7528\u4e24\u4e2a\u6b8b\u5dee\u5757\u8fdb\u884c\u5904\u7406\u3002

\n", "

Scale down the feature map by _^_0_^_

\n": "

\u6309\u6bd4\u4f8b\u7f29\u5c0f\u8981\u7d20\u5730\u56fe_^_0_^_

\n", "

Scale up the feature map by _^_0_^_

\n": "

\u6309\u6bd4\u4f8b\u653e\u5927\u8981\u7d20\u5730\u56fe_^_0_^_

\n", "

Swish activation function

\n

_^_0_^_

\n": "

Swish \u6fc0\u6d3b\u529f\u80fd

\n

_^_0_^_

\n", "

Up block

\n

This combines _^_0_^_ and _^_1_^_. These are used in the second half of U-Net at each resolution.

\n": "

\u5411\u4e0a\u65b9\u5757

\n

\u8fd9\u7ed3\u5408\u4e86_^_0_^_\u548c_^_1_^_.\u8fd9\u4e9b\u5728U-Net\u7684\u540e\u534a\u90e8\u5206\u4ee5\u6bcf\u79cd\u5206\u8fa8\u7387\u4f7f\u7528\u3002

\n", "

First half of U-Net - decreasing resolution

\n": "

U-Net \u7684\u524d\u534a\u90e8\u5206-\u5206\u8fa8\u7387\u964d\u4f4e

\n", "

Second half of U-Net - increasing resolution

\n": "

U-Net \u7684\u540e\u534a\u90e8\u5206-\u63d0\u9ad8\u5206\u8fa8\u7387

\n", "

\n": "

\n", "

_^_0_^_ at the same resolution

\n": "

_^_0_^_\u4ee5\u76f8\u540c\u7684\u5206\u8fa8\u7387

\n", "

_^_0_^_ is not used, but it's kept in the arguments because for the attention layer function signature to match with _^_1_^_.

\n": "

_^_0_^_\u672a\u4f7f\u7528\uff0c\u4f46\u5b83\u4fdd\u7559\u5728\u53c2\u6570\u4e2d\uff0c\u56e0\u4e3a\u8981\u4e0e\u6ce8\u610f\u5c42\u51fd\u6570\u7b7e\u540d\u5339\u914d_^_1_^_\u3002

\n", "

_^_0_^_ will store outputs at each resolution for skip connection

\n": "

_^_0_^_\u5c06\u4ee5\u6bcf\u79cd\u5206\u8fa8\u7387\u5b58\u50a8\u8f93\u51fa\u4ee5\u8fdb\u884c\u8df3\u8fc7\u8fde\u63a5

\n", "

Activation

\n": "

\u6fc0\u6d3b

\n", "

Add _^_0_^_

\n": "

\u6dfb\u52a0_^_0_^_

\n", "

Add skip connection

\n": "

\u6dfb\u52a0\u8df3\u8fc7\u8fde\u63a5

\n", "

Add the shortcut connection and return

\n": "

\u6dfb\u52a0\u5feb\u6377\u65b9\u5f0f\u8fde\u63a5\u5e76\u8fd4\u56de

\n", "

Add time embeddings

\n": "

\u6dfb\u52a0\u65f6\u95f4\u5d4c\u5165

\n", "

Calculate scaled dot-product _^_0_^_

\n": "

\u8ba1\u7b97\u7f29\u653e\u7684\u70b9\u79ef_^_0_^_

\n", "

Change _^_0_^_ to shape _^_1_^_

\n": "

\u6539_^_0_^_\u6210\u5f62\u72b6_^_1_^_

\n", "

Change to shape _^_0_^_

\n": "

\u6539\u6210\u5f62\u72b6_^_0_^_

\n", "

Combine the set of modules

\n": "

\u7ec4\u5408\u8fd9\u7ec4\u6a21\u5757

\n", "

Create sinusoidal position embeddings same as those from the transformer

\n_^_0_^_

where _^_1_^_ is _^_2_^_

\n": "

\u521b\u5efa\u4e0e\u53d8\u538b\u5668\u76f8\u540c\u7684\u6b63\u5f26\u4f4d\u7f6e\u5d4c\u5165

\n_^_0_^_

\u5728\u54ea_^_1_^_\u91cc_^_2_^_

\n", "

Default _^_0_^_

\n": "

\u9ed8\u8ba4_^_0_^_

\n", "

Down sample at all resolutions except the last

\n": "

\u9664\u6700\u540e\u4e00\u4e2a\u5206\u8fa8\u7387\u4e4b\u5916\u7684\u6240\u6709\u5206\u8fa8\u7387\u90fd\u5411\u4e0b\u91c7\u6837

\n", "

Final block to reduce the number of channels

\n": "

\u51cf\u5c11\u4fe1\u9053\u6570\u91cf\u7684\u6700\u7ec8\u533a\u5757

\n", "

Final normalization and convolution

\n": "

\u6700\u7ec8\u5f52\u4e00\u5316\u548c\u5377\u79ef

\n", "

Final normalization and convolution layer

\n": "

\u6700\u7ec8\u5f52\u4e00\u5316\u548c\u5377\u79ef\u5c42

\n", "

First convolution layer

\n": "

\u7b2c\u4e00\u4e2a\u5377\u79ef\u5c42

\n", "

First half of U-Net

\n": "

U-Net \u7684\u4e0a\u534a\u5e74

\n", "

First linear layer

\n": "

\u7b2c\u4e00\u4e2a\u7ebf\u6027\u5c42

\n", "

For each resolution

\n": "

\u5bf9\u4e8e\u6bcf\u79cd\u5206\u8fa8\u7387

\n", "

Get image projection

\n": "

\u83b7\u53d6\u56fe\u50cf\u6295\u5f71

\n", "

Get query, key, and values (concatenated) and shape it to _^_0_^_

\n": "

\u83b7\u53d6\u67e5\u8be2\u3001\u952e\u548c\u503c\uff08\u4e32\u8054\uff09\u5e76\u5c06\u5176\u8c03\u6574\u4e3a_^_0_^_

\n", "

Get shape

\n": "

\u5851\u9020\u8eab\u6750

\n", "

Get the skip connection from first half of U-Net and concatenate

\n": "

\u4ece U-Net \u7684\u524d\u534a\u90e8\u5206\u83b7\u53d6\u8df3\u8fc7\u8fde\u63a5\u5e76\u8fde\u63a5

\n", "

Get time-step embeddings

\n": "

\u83b7\u53d6\u65f6\u95f4\u6b65\u957f\u5d4c\u5165

\n", "

Group normalization and the first convolution layer

\n": "

\u7ec4\u5f52\u4e00\u5316\u548c\u7b2c\u4e00\u4e2a\u5377\u79ef\u5c42

\n", "

Group normalization and the second convolution layer

\n": "

\u7ec4\u5f52\u4e00\u5316\u548c\u7b2c\u4e8c\u4e2a\u5377\u79ef\u5c42

\n", "

If the number of input channels is not equal to the number of output channels we have to project the shortcut connection

\n": "

\u5982\u679c\u8f93\u5165\u901a\u9053\u7684\u6570\u91cf\u4e0d\u7b49\u4e8e\u8f93\u51fa\u901a\u9053\u7684\u6570\u91cf\uff0c\u6211\u4eec\u5fc5\u987b\u6295\u5f71\u5feb\u6377\u65b9\u5f0f\u8fde\u63a5

\n", "

Linear layer for final transformation

\n": "

\u7528\u4e8e\u6700\u7ec8\u53d8\u6362\u7684\u7ebf\u6027\u5c42

\n", "

Linear layer for time embeddings

\n": "

\u7528\u4e8e\u65f6\u95f4\u5d4c\u5165\u7684\u7ebf\u6027\u5c42

\n", "

Middle (bottom)

\n": "

\u4e2d\u95f4\uff08\u5e95\u90e8\uff09

\n", "

Middle block

\n": "

\u4e2d\u95f4\u65b9\u5757

\n", "

Multiply by values

\n": "

\u4e58\u4ee5\u503c

\n", "

Normalization layer

\n": "

\u5f52\u4e00\u5316\u5c42

\n", "

Number of channels

\n": "

\u9891\u9053\u6570\u91cf

\n", "

Number of output channels at this resolution

\n": "

\u6b64\u5206\u8fa8\u7387\u4e0b\u7684\u8f93\u51fa\u58f0\u9053\u6570

\n", "

Number of resolutions

\n": "

\u5206\u8fa8\u7387\u6570\u91cf

\n", "

Project image into feature map

\n": "

\u5c06\u56fe\u50cf\u6295\u5f71\u5230\u8981\u7d20\u5730\u56fe\u4e2d

\n", "

Projections for query, key and values

\n": "

\u67e5\u8be2\u3001\u952e\u548c\u503c\u7684\u6295\u5f71

\n", "

Reshape to _^_0_^_

\n": "

\u91cd\u5851\u4e3a_^_0_^_

\n", "

Scale for dot-product attention

\n": "

\u7f29\u653e\u70b9\u4ea7\u54c1\u6ce8\u610f\u529b

\n", "

Second convolution layer

\n": "

\u7b2c\u4e8c\u4e2a\u5377\u79ef\u5c42

\n", "

Second half of U-Net

\n": "

U-Net \u7684\u4e0b\u534a\u573a

\n", "

Second linear layer

\n": "

\u7b2c\u4e8c\u4e2a\u7ebf\u6027\u5c42

\n", "

Softmax along the sequence dimension _^_0_^_

\n": "

\u987a\u5e8f\u7ef4\u5ea6\u4e0a\u7684 Softmax_^_0_^_

\n", "

Split query, key, and values. Each of them will have shape _^_0_^_

\n": "

\u62c6\u5206\u67e5\u8be2\u3001\u952e\u548c\u503c\u3002\u4ed6\u4eec\u6bcf\u4e2a\u4eba\u90fd\u4f1a\u6709\u5f62\u72b6_^_0_^_

\n", "

The input has _^_0_^_ because we concatenate the output of the same resolution from the first half of the U-Net

\n": "

\u8f93\u5165\u4e4b_^_0_^_\u6240\u4ee5\u6709\uff0c\u662f\u56e0\u4e3a\u6211\u4eec\u5c06 U-Net \u524d\u534a\u90e8\u5206\u76f8\u540c\u5206\u8fa8\u7387\u7684\u8f93\u51fa\u8fde\u63a5\u8d77\u6765

\n", "

Time embedding layer. Time embedding has _^_0_^_ channels

\n": "

\u65f6\u95f4\u5d4c\u5165\u5c42\u3002\u65f6\u95f4\u5d4c\u5165\u6709_^_0_^_\u9891\u9053

\n", "

Transform to _^_0_^_

\n": "

\u53d8\u6362\u4e3a_^_0_^_

\n", "

Transform with the MLP

\n": "

\u4f7f\u7528 MLP \u8fdb\u884c\u8f6c\u578b

\n", "

Up sample at all resolutions except last

\n": "

\u9664\u6700\u540e\u4e00\u4e2a\u4ee5\u5916\u7684\u6240\u6709\u5206\u8fa8\u7387\u5411\u4e0a\u91c7\u6837

\n", "\n": "\n", "\n": "\n", "\n": "\n", "\n": "\n", "\n": "\n", "U-Net model for Denoising Diffusion Probabilistic Models (DDPM)": "\u7528\u4e8e\u53bb\u566a\u6269\u6563\u6982\u7387\u6a21\u578b (DDPM) \u7684 U-Net \u6a21\u578b", "UNet model for Denoising Diffusion Probabilistic Models (DDPM)": "\u7528\u4e8e\u53bb\u566a\u6269\u6563\u6982\u7387\u6a21\u578b (DDPM) \u7684 unET \u6a21\u578b" }