From c483ad25ae93b98295c6022eac7d00fcc3d014bd Mon Sep 17 00:00:00 2001 From: yuhan Date: Wed, 16 Apr 2025 16:32:28 +0800 Subject: [PATCH] modify format --- MindFlow/mindflow/cell/diffusion.py | 10 +++++----- .../cell/mindflow.cell.AttentionBlock.rst | 2 +- ...low.cell.ConditionDiffusionTransformer.rst | 20 +++++++++---------- .../cell/mindflow.cell.DDIMScheduler.rst | 2 +- .../cell/mindflow.cell.DDPMScheduler.rst | 2 +- .../cell/mindflow.cell.MultiHeadAttention.rst | 2 +- .../mindflow/cell/mindflow.cell.SNO2D.rst | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/MindFlow/mindflow/cell/diffusion.py b/MindFlow/mindflow/cell/diffusion.py index 2c0f21d5a..ee2b8b67d 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 31db168b0..5791d69b5 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 c3565c421..2120e756d 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 c43df180d..de0b668a2 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 e12deb707..ff7b90195 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 0dcdd374d..145c1e24c 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 cee9ea993..0d3ef1e99 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`。 -- Gitee