diff --git a/MindFlow/mindflow/cell/diffusion.py b/MindFlow/mindflow/cell/diffusion.py index 2c0f21d5a3d35a4c743198c53dce2b6ca6e21cc8..ee2b8b67d084322de54546f724afac4f81e4f725 100644 --- a/MindFlow/mindflow/cell/diffusion.py +++ b/MindFlow/mindflow/cell/diffusion.py @@ -407,7 +407,7 @@ class DDPMScheduler(DiffusionScheduler): rescale_betas_zero_snr (bool): Whether to rescale the betas to have zero terminal SNR. This enables the model to generate very bright and dark samples instead of limiting it to samples with medium brightness. Loosely related to `offset_noise `_. Default: ``False``. - compute_dtype: the dtype of compute, it can be `mstype.float32` or `mstype.float16`. Default: ``mstype.float32``, indicates ``mindspore.float32``. + compute_dtype (mindspore.dtype): the dtype of compute, it can be `mstype.float32` or `mstype.float16`. Default: ``mstype.float32``, indicates ``mindspore.float32``. Supported Platforms: ``Ascend`` @@ -706,11 +706,11 @@ class DDIMScheduler(DiffusionScheduler): clipping has happened, "corrected" `model_output` would coincide with the one provided as input and `use_clipped_model_output` has no effect. Default: ``False.``. - Raises: - ValueError: If `eta` not in [0, 1]. - Returns: Tensor, Denoised output x_prev. + + Raises: + ValueError: If `eta` not in [0, 1]. """ # See formulas (12) and (16) of DDIM paper `Denoising Diffusion Implicit Models `_ # Ideally, read DDIM paper in-detail understanding @@ -1054,7 +1054,7 @@ class DiffusionTrainer: model (nn.Cell): The diffusion backbone model. scheduler (DiffusionScheduler): DDPM or DDIM scheduler. objective (str): Prediction type of the scheduler function; - can be `pred_noise` (predicts the noise of the diffusion process), `pred_x0` (predicts the original sample`) or + can be `pred_noise` (predicts the noise of the diffusion process), `pred_x0` (predicts the original sample) or `pred_v` (see section 2.4 of `Imagen Video `_ paper). Default: ``pred_noise``. p2_loss_weight_gamma (float): p2 loss weight gamma, from `Perception Prioritized Training of Diffusion Models `_. Default: ``0``. diff --git a/docs/api_python/mindflow/cell/mindflow.cell.AttentionBlock.rst b/docs/api_python/mindflow/cell/mindflow.cell.AttentionBlock.rst index 31db168b0f078416309eb2454aef0a1daf2089ea..5791d69b51efff0843048c801abe5e4ec0594daa 100644 --- a/docs/api_python/mindflow/cell/mindflow.cell.AttentionBlock.rst +++ b/docs/api_python/mindflow/cell/mindflow.cell.AttentionBlock.rst @@ -1,7 +1,7 @@ mindflow.cell.AttentionBlock ============================ -.. py:class:: mindflow.cell.AttentionBlock(in_channels, num_heads, drop_mode='dropout', dropout_rate='0.0', compute_dtype=mstype.float32) +.. py:class:: mindflow.cell.AttentionBlock(in_channels, num_heads, drop_mode='dropout', dropout_rate=0.0, compute_dtype=mstype.float32) `AttentionBlock` 包含 `MultiHeadAttention` 和 `MLP` 网络堆叠而成。 diff --git a/docs/api_python/mindflow/cell/mindflow.cell.ConditionDiffusionTransformer.rst b/docs/api_python/mindflow/cell/mindflow.cell.ConditionDiffusionTransformer.rst index c3565c42167840a8bee1dcdd9ba58b54c220b6ba..2120e756de6d0f19f8e9c3f0043e7bf5d64f05b7 100644 --- a/docs/api_python/mindflow/cell/mindflow.cell.ConditionDiffusionTransformer.rst +++ b/docs/api_python/mindflow/cell/mindflow.cell.ConditionDiffusionTransformer.rst @@ -1,20 +1,20 @@ mindflow.cell.ConditionDiffusionTransformer ================================================== -.. py:class:: mindflow.cell.ConditionDiffusionTransformer(in_channels, out_channels, cond_channels, hidden_channels, cond_channels, layers, heads, time_token_cond=True, compute_dtype=mstype.float32) +.. py:class:: mindflow.cell.ConditionDiffusionTransformer(in_channels, out_channels, cond_channels, hidden_channels, layers, heads, time_token_cond=True, cond_as_token=True, compute_dtype=mstype.float32) 以Transformer作为骨干网络的条件控制扩散模型。 参数: - in_channels (int):输入特征维度。 - out_channels (int):输出特征维度。 - hidden_channels (int):隐藏层特征维度。 - cond_channels (int): 条件特征维度。 - layers (int): `Transformer` 层数。 - heads (int): 注意力头数. - time_token_cond (bool):是否将时间作为条件token。 Default: ``True`` 。 - cond_as_token (bool):是否将条件作为token。Default: ``True`` 。 - compute_dtype (mindspore.dtype):计算数据类型。支持 ``mstype.float32`` or ``mstype.float16`` 。默认值: ``mstype.float32`` ,表示 ``mindspore.float32`` 。 + - **in_channels** (int) - 输入特征维度。 + - **out_channels** (int) - 输出特征维度。 + - **hidden_channels** (int) - 隐藏层特征维度。 + - **cond_channels** (int) - 条件特征维度。 + - **layers** (int) - `Transformer` 层数。 + - **heads** (int) - 注意力头数。 + - **time_token_cond** (bool) - 是否将时间作为条件token。Default: ``True`` 。 + - **cond_as_token** (bool) - 是否将条件作为token。Default: ``True`` 。 + - **compute_dtype** (mindspore.dtype) - 计算数据类型。支持 ``mstype.float32`` or ``mstype.float16`` 。默认值: ``mstype.float32`` ,表示 ``mindspore.float32`` 。 输入: - **x** (Tensor) - 网络输入。shape为 :math:`(batch\_size, sequence\_len, in\_channels)` 的Tensor。 diff --git a/docs/api_python/mindflow/cell/mindflow.cell.DDIMScheduler.rst b/docs/api_python/mindflow/cell/mindflow.cell.DDIMScheduler.rst index c43df180dac6dd711cf9dfd3f2199129a9ed68c9..de0b668a26983e7d3e8f44f3c81efa62ae0539fb 100644 --- a/docs/api_python/mindflow/cell/mindflow.cell.DDIMScheduler.rst +++ b/docs/api_python/mindflow/cell/mindflow.cell.DDIMScheduler.rst @@ -42,7 +42,7 @@ mindflow.cell.DDIMScheduler 异常: - **ValueError** - 如果 `num_inference_steps` 大于 `num_train_timesteps` 。 - .. py:method:: step(model_output, sample, timestep, eta=0.0, use_clipped_model_output=False) + .. py:method:: step(model_output: Tensor, sample: Tensor, timestep: Tensor, eta: float = 0.0, use_clipped_model_output: bool = False) DDIM反向去噪步骤。 diff --git a/docs/api_python/mindflow/cell/mindflow.cell.DDPMScheduler.rst b/docs/api_python/mindflow/cell/mindflow.cell.DDPMScheduler.rst index e12deb7075cdb4a92f5cdd69fa6cc504cdef2250..ff7b901951a65d62e5b275e613bfa5540e401739 100644 --- a/docs/api_python/mindflow/cell/mindflow.cell.DDPMScheduler.rst +++ b/docs/api_python/mindflow/cell/mindflow.cell.DDPMScheduler.rst @@ -21,7 +21,7 @@ mindflow.cell.DDPMScheduler - **rescale_betas_zero_snr** (bool) - 是否重新缩放 betas 以使其终端 SNR 为零。这使模型能够生成非常明亮和黑暗的样本,而不是将其限制为中等亮度的样本。与 `offset_noise `_ 松散相关。默认值: ``False`` 。 - **compute_dtype** (mindspore.dtype) - 数据类型。默认值: ``mstype.float32`` ,表示 ``mindspore.float32`` 。 - .. py:method:: add_noise(original_samples, noise, timesteps) + .. py:method:: add_noise(original_samples: Tensor, noise: Tensor, timesteps: Tensor) DDPM前向加噪步骤。 diff --git a/docs/api_python/mindflow/cell/mindflow.cell.MultiHeadAttention.rst b/docs/api_python/mindflow/cell/mindflow.cell.MultiHeadAttention.rst index 0dcdd374d71ac5473da5880b18e1100cb9126d3e..145c1e24cda6d82cadae9290d2c5944dcf9054f4 100644 --- a/docs/api_python/mindflow/cell/mindflow.cell.MultiHeadAttention.rst +++ b/docs/api_python/mindflow/cell/mindflow.cell.MultiHeadAttention.rst @@ -1,7 +1,7 @@ mindflow.cell.MultiHeadAttention ================================= -.. py:class:: mindflow.cell.MultiHeadAttention(in_channels, num_heads, drop_mode='dropout', dropout_rate='0.0', compute_dtype=mstype.float32) +.. py:class:: mindflow.cell.MultiHeadAttention(in_channels, num_heads, drop_mode='dropout', dropout_rate=0.0, compute_dtype=mstype.float32) 多头注意力机制,具体细节可以参见 `Attention Is All You Need `_ 。 diff --git a/docs/api_python/mindflow/cell/mindflow.cell.SNO2D.rst b/docs/api_python/mindflow/cell/mindflow.cell.SNO2D.rst index cee9ea99319cb91a74169cfaf898bc15d4ae1db6..0d3ef1e99348948ce175ecc49f621dcef3c01d91 100644 --- a/docs/api_python/mindflow/cell/mindflow.cell.SNO2D.rst +++ b/docs/api_python/mindflow/cell/mindflow.cell.SNO2D.rst @@ -1,6 +1,6 @@ mindflow.cell.SNO2D ========================= -.. py:class:: mindflow.cell.SNO2D(in_channels, out_channels, hidden_channels=64, num_sno_layers=3, data_format="channels_first", transforms=None, kernel_size=5, activation="gelu", compute_dtype=mstype.float32) +.. py:class:: mindflow.cell.SNO2D(in_channels, out_channels, hidden_channels=64, num_sno_layers=3, data_format="channels_first", transforms=None, kernel_size=5, num_usno_layers=0, num_unet_strides=1, activation="gelu", compute_dtype=mstype.float32) 二维谱神经算子,包含一个提升层(编码器)、多个谱变换层(谱空间的线性变换)和一个投影层(解码器)。参见基类文档 :class:`mindflow.cell.SNO`。