diff --git a/MindFlow/mindflow/core/losses.py b/MindFlow/mindflow/core/losses.py index 404d0ed5a7d9a987f1cbf146c55a97f862435952..d4e2bb70569382a19ceaeb4047c547bc1680cfb7 100644 --- a/MindFlow/mindflow/core/losses.py +++ b/MindFlow/mindflow/core/losses.py @@ -164,10 +164,10 @@ class MTLWeightedLoss(WeightedLossCell): is higher than certain constant given. Inputs: - - **input** - tuple of Tensors. + - **input** (tuple[Tensor]) - The input data. Outputs: - Tensor. losses for MTL weighted strategy. + Tensor. Losses for MTL weighted strategy. Supported Platforms: ``Ascend`` ``GPU`` @@ -220,7 +220,7 @@ class WaveletTransformLoss(nn.LossBase): The multi-level wavelet transformation losses. Args: - wave_level (int): The number of the wavelet transformation levels, should be positive integer. + wave_level (int): The number of the wavelet transformation levels, should be positive integer. Default: ``2``. regroup (bool): The regroup error combination form of the wavelet transformation losses. Default: ``"False"``. Inputs: @@ -229,11 +229,7 @@ class WaveletTransformLoss(nn.LossBase): P denotes the patch size. C denots the feature channels. Outputs: - Tensor. - - Raises: - TypeError: if `wave_level` is not an int. - TypeError: if `regroup` is not a bool. + Tensor. Losses for multi-level wavelet transformation. Supported Platforms: ``Ascend`` ``GPU`` diff --git a/docs/api_python/mindflow/loss/mindflow.loss.MTLWeightedLoss.rst b/docs/api_python/mindflow/core/mindflow.core.MTLWeightedLoss.rst similarity index 85% rename from docs/api_python/mindflow/loss/mindflow.loss.MTLWeightedLoss.rst rename to docs/api_python/mindflow/core/mindflow.core.MTLWeightedLoss.rst index 776ef481f1c21f29b3bf033e1710dcd94722906f..30171e7bebba20819110e19d665ec9f2389e2d22 100644 --- a/docs/api_python/mindflow/loss/mindflow.loss.MTLWeightedLoss.rst +++ b/docs/api_python/mindflow/core/mindflow.core.MTLWeightedLoss.rst @@ -1,7 +1,7 @@ -mindflow.loss.MTLWeightedLoss +mindflow.core.MTLWeightedLoss ================================= -.. py:class:: mindflow.loss.MTLWeightedLoss(num_losses, bound_param=0.0) +.. py:class:: mindflow.core.MTLWeightedLoss(num_losses, bound_param=0.0) 计算MTL策略自动加权多任务损失。请参考 `自动加权进行多任务学习 `_ 。 diff --git a/docs/api_python/mindflow/loss/mindflow.loss.RelativeRMSELoss.rst b/docs/api_python/mindflow/core/mindflow.core.RelativeRMSELoss.rst similarity index 92% rename from docs/api_python/mindflow/loss/mindflow.loss.RelativeRMSELoss.rst rename to docs/api_python/mindflow/core/mindflow.core.RelativeRMSELoss.rst index e0f05a4f41713220fd4153cf07649a3d271b1ce6..d680698e9f2e4e20c3401fe199ec4b9db6c2bc01 100644 --- a/docs/api_python/mindflow/loss/mindflow.loss.RelativeRMSELoss.rst +++ b/docs/api_python/mindflow/core/mindflow.core.RelativeRMSELoss.rst @@ -1,7 +1,7 @@ -mindflow.loss.RelativeRMSELoss +mindflow.core.RelativeRMSELoss ============================== -.. py:class:: mindflow.loss.RelativeRMSELoss(reduction="sum") +.. py:class:: mindflow.core.RelativeRMSELoss(reduction="sum") 相对均方根误差(RRMSE)是由均方根值归一化的均方根误差,其中每个残差都是根据实际值缩放的。 Relative RMSELoss用来测量 :math:`x` 和 :math:`y` 之间的相对均方根误差,其中 :math:`x` 是预测值, :math:`y` 是目标值。 diff --git a/docs/api_python/mindflow/loss/mindflow.loss.WaveletTransformLoss.rst b/docs/api_python/mindflow/core/mindflow.core.WaveletTransformLoss.rst similarity index 64% rename from docs/api_python/mindflow/loss/mindflow.loss.WaveletTransformLoss.rst rename to docs/api_python/mindflow/core/mindflow.core.WaveletTransformLoss.rst index d29751757a664759a7e7da12b5261a74b35e87ea..bf3bc6af1bee07e57c06a3c04b9e4e4d2db3f0fe 100644 --- a/docs/api_python/mindflow/loss/mindflow.loss.WaveletTransformLoss.rst +++ b/docs/api_python/mindflow/core/mindflow.core.WaveletTransformLoss.rst @@ -1,20 +1,16 @@ -mindflow.loss.WaveletTransformLoss -================================== - -.. py:class:: mindflow.loss.WaveletTransformLoss(wave_level=2, regroup=False) - - 多级小波变换损失。 - - 参数: - - **wave_level** (int) - 小波变换级数,应为正整数。默认值: ``2``。 - - **regroup** (bool) - 小波变换损失的regroup误差组合形式。默认值: ``False``。 - - 输入: - - **input** - 张量构成的tuple。Tensor的shape为 :math:`(B*H*W/(P*P), P*P*C)` ,其中B表示批次大小。H、W分别表示图像的高度和宽度。P表示补丁大小。C表示特征通道。 - - 输出: - Tensor。小波变换损失函数输出。 - - 异常: - - **TypeError** - 如果 `wave_level` 不是int。 - - **TypeError** - 如果 `regroup` bool。 \ No newline at end of file +mindflow.core.WaveletTransformLoss +================================== + +.. py:class:: mindflow.core.WaveletTransformLoss(wave_level=2, regroup=False) + + 多级小波变换损失。 + + 参数: + - **wave_level** (int) - 小波变换级数,应为正整数。默认值: ``2``。 + - **regroup** (bool) - 小波变换损失的regroup误差组合形式。默认值: ``False``。 + + 输入: + - **input** - 张量构成的tuple。Tensor的shape为 :math:`(B*H*W/(P*P), P*P*C)` ,其中B表示批次大小。H、W分别表示图像的高度和宽度。P表示补丁大小。C表示特征通道。 + + 输出: + Tensor。小波变换损失函数输出。 \ No newline at end of file diff --git a/docs/api_python/mindflow/operators/mindflow.operators.batched_hessian.rst b/docs/api_python/mindflow/core/mindflow.core.batched_hessian.rst similarity index 53% rename from docs/api_python/mindflow/operators/mindflow.operators.batched_hessian.rst rename to docs/api_python/mindflow/core/mindflow.core.batched_hessian.rst index 72ccfdfd22f3a0b5834ff592a8d513d1f6b77ced..c310bfed9ae1ef1b946d7c14c8884a505ead9c27 100644 --- a/docs/api_python/mindflow/operators/mindflow.operators.batched_hessian.rst +++ b/docs/api_python/mindflow/core/mindflow.core.batched_hessian.rst @@ -1,7 +1,7 @@ -mindflow.operators.batched_hessian +mindflow.core.batched_hessian ================================== -.. py:function:: mindflow.operators.batched_hessian(model) +.. py:function:: mindflow.core.batched_hessian(model) 计算网络模型的海森矩阵。 @@ -9,7 +9,7 @@ mindflow.operators.batched_hessian - **model** (mindspore.nn.Cell) - 输入维度为in_channels输出维度为out_channels的网络模型。 返回: - Function,用于计算海森矩阵的Hessian实例。输入维度为:[batch_size,in_channels],输出维度为:[out_channels,in_channels,batch_size,in_channels]。 + Jacobian(Tensor),用于计算海森矩阵的Hessian实例。输入维度为:[batch_size,in_channels],输出维度为:[out_channels,in_channels,batch_size,in_channels]。 .. note:: 要求MindSpore版本 >= 2.0.0调用如下接口: `mindspore.jacrev` 。 \ No newline at end of file diff --git a/docs/api_python/mindflow/operators/mindflow.operators.batched_jacobian.rst b/docs/api_python/mindflow/core/mindflow.core.batched_jacobian.rst similarity index 54% rename from docs/api_python/mindflow/operators/mindflow.operators.batched_jacobian.rst rename to docs/api_python/mindflow/core/mindflow.core.batched_jacobian.rst index 27f29b298311f70331312e8d177029a962875665..581127b162c8017ae9786aaf7ba9078c9bd7a582 100644 --- a/docs/api_python/mindflow/operators/mindflow.operators.batched_jacobian.rst +++ b/docs/api_python/mindflow/core/mindflow.core.batched_jacobian.rst @@ -1,7 +1,7 @@ -mindflow.operators.batched_jacobian +mindflow.core.batched_jacobian =================================== -.. py:function:: mindflow.operators.batched_jacobian(model) +.. py:function:: mindflow.core.batched_jacobian(model) 计算网络模型的雅可比矩阵。 @@ -9,7 +9,7 @@ mindflow.operators.batched_jacobian - **model** (mindspore.nn.Cell) - 输入维度为in_channels输出维度为out_channels的网络模型。 返回: - Function,用于计算雅可比矩阵的Jacobian实例。输入维度为:[batch_size,in_channels],输出维度为:[out_channels,batch_size,in_channels]。 + Hessian(Tensor),用于计算雅可比矩阵的Jacobian实例。输入维度为:[batch_size,in_channels],输出维度为:[out_channels,batch_size,in_channels]。 .. note:: 要求MindSpore版本 >= 2.0.0调用如下接口: `mindspore.jacrev` 。 \ No newline at end of file diff --git a/docs/api_python/mindflow/loss/mindflow.loss.get_loss_metric.rst b/docs/api_python/mindflow/core/mindflow.core.get_loss_metric.rst similarity index 67% rename from docs/api_python/mindflow/loss/mindflow.loss.get_loss_metric.rst rename to docs/api_python/mindflow/core/mindflow.core.get_loss_metric.rst index d2f583eef9fc0feb52dff72a5c555d74abe5aee0..75b56a7d652d37f1b63a067c8eeb7974742e4f0c 100644 --- a/docs/api_python/mindflow/loss/mindflow.loss.get_loss_metric.rst +++ b/docs/api_python/mindflow/core/mindflow.core.get_loss_metric.rst @@ -1,7 +1,7 @@ -mindflow.loss.get_loss_metric +mindflow.core.get_loss_metric ============================= -.. py:function:: mindflow.loss.get_loss_metric(name) +.. py:function:: mindflow.core.get_loss_metric(name) 获取损失函数。 diff --git a/docs/api_python/mindflow/common/mindflow.common.get_multi_step_lr.rst b/docs/api_python/mindflow/core/mindflow.core.get_multi_step_lr.rst similarity index 89% rename from docs/api_python/mindflow/common/mindflow.common.get_multi_step_lr.rst rename to docs/api_python/mindflow/core/mindflow.core.get_multi_step_lr.rst index c3fe69ae53085113c56274f95e4a65a2ffc7c42c..adcf05de6c339611492c2dd0df0f81743cef70a8 100644 --- a/docs/api_python/mindflow/common/mindflow.common.get_multi_step_lr.rst +++ b/docs/api_python/mindflow/core/mindflow.core.get_multi_step_lr.rst @@ -1,7 +1,7 @@ -mindflow.common.get_multi_step_lr +mindflow.core.get_multi_step_lr ================================= -.. py:function:: mindflow.common.get_multi_step_lr(lr_init, milestones, gamma, steps_per_epoch, last_epoch) +.. py:function:: mindflow.core.get_multi_step_lr(lr_init, milestones, gamma, steps_per_epoch, last_epoch) epoch的数量到达其中一个milestone时,学习率按 `gamma` 进行衰减,生成学习率数组。 diff --git a/docs/api_python/mindflow/common/mindflow.common.get_poly_lr.rst b/docs/api_python/mindflow/core/mindflow.core.get_poly_lr.rst similarity index 85% rename from docs/api_python/mindflow/common/mindflow.common.get_poly_lr.rst rename to docs/api_python/mindflow/core/mindflow.core.get_poly_lr.rst index bdb5ab47ff869b02a6d508939c1fe5abf13f206e..708bc3e7c1a057cd86110569512656c1de03d483 100644 --- a/docs/api_python/mindflow/common/mindflow.common.get_poly_lr.rst +++ b/docs/api_python/mindflow/core/mindflow.core.get_poly_lr.rst @@ -1,7 +1,7 @@ -mindflow.common.get_poly_lr +mindflow.core.get_poly_lr =========================== -.. py:function:: mindflow.common.get_poly_lr(global_step, lr_init, lr_end, lr_max, warmup_steps, total_steps, poly_power) +.. py:function:: mindflow.core.get_poly_lr(global_step, lr_init, lr_end, lr_max, warmup_steps, total_steps, poly_power) 生成指数衰减的学习率。学习率随着训练步数进行指数衰减。当step小于warmup_steps时,:math:`lr = step * (lr\_max - lr\_init)/warmup\_steps` ,之后 :math:`lr = lr\_end + (lr\_max - lr\_end) * [(1 - i + step)/(total\_steps - warmup\_steps)]**poly\_power`。 diff --git a/docs/api_python/mindflow/common/mindflow.common.get_warmup_cosine_annealing_lr.rst b/docs/api_python/mindflow/core/mindflow.core.get_warmup_cosine_annealing_lr.rst similarity index 87% rename from docs/api_python/mindflow/common/mindflow.common.get_warmup_cosine_annealing_lr.rst rename to docs/api_python/mindflow/core/mindflow.core.get_warmup_cosine_annealing_lr.rst index f54dda046f5bbe808f1af82f4d04367809d1bc71..b0f8cba1401073b4db1109d6d7ea625341b634db 100644 --- a/docs/api_python/mindflow/common/mindflow.common.get_warmup_cosine_annealing_lr.rst +++ b/docs/api_python/mindflow/core/mindflow.core.get_warmup_cosine_annealing_lr.rst @@ -1,7 +1,7 @@ -mindflow.common.get_warmup_cosine_annealing_lr +mindflow.core.get_warmup_cosine_annealing_lr ============================================== -.. py:function:: mindflow.common.get_warmup_cosine_annealing_lr(lr_init, steps_per_epoch, last_epoch, warmup_epochs=0, warmup_lr_init=0.0, eta_min=1e-6) +.. py:function:: mindflow.core.get_warmup_cosine_annealing_lr(lr_init, steps_per_epoch, last_epoch, warmup_epochs=0, warmup_lr_init=0.0, eta_min=1e-6) 基于余弦函数生成衰减学习率数组。如果指定了预热epoch,将通过线性方法对预热epoch进行预热。 对于第 `i` 步,计算余弦衰减的学习速率decayed_learning_rate[i]的表达式为: @@ -10,7 +10,7 @@ mindflow.common.get_warmup_cosine_annealing_lr decayed\_learning\_rate[i] = eta\_min + 0.5 * (lr\_init - eta\_min) * (1 + cos(\frac{current\_epoch}{last\_epoch}\pi)) - 其中 :math:`current\_epoch = floor(\frac{i}{steps\_per\_epoch})` . + 其中 :math:`current\_epoch = floor(\frac{i}{steps\_per\_epoch})` 。 如果指定了预热epoch,对于预热epoch的第 `i` 步,预热学习速率的计算表达式warmup_learning_rate[i]为: diff --git a/docs/api_python/mindflow/mindflow.common.rst b/docs/api_python/mindflow/mindflow.common.rst deleted file mode 100644 index ba981062cbf90b15470cd63148703fb03d4cd60f..0000000000000000000000000000000000000000 --- a/docs/api_python/mindflow/mindflow.common.rst +++ /dev/null @@ -1,11 +0,0 @@ -mindflow.common -================== - -.. mscnplatformautosummary:: - :toctree: common - :nosignatures: - :template: classtemplate.rst - - mindflow.common.get_multi_step_lr - mindflow.common.get_poly_lr - mindflow.common.get_warmup_cosine_annealing_lr \ No newline at end of file diff --git a/docs/api_python/mindflow/mindflow.core.rst b/docs/api_python/mindflow/mindflow.core.rst new file mode 100644 index 0000000000000000000000000000000000000000..3bf67302f0723330de842543640ced431f087d1c --- /dev/null +++ b/docs/api_python/mindflow/mindflow.core.rst @@ -0,0 +1,17 @@ +mindflow.core +================== + +.. mscnplatformautosummary:: + :toctree: core + :nosignatures: + :template: classtemplate.rst + + mindflow.core.get_multi_step_lr + mindflow.core.get_poly_lr + mindflow.core.get_warmup_cosine_annealing_lr + mindflow.core.MTLWeightedLoss + mindflow.core.RelativeRMSELoss + mindflow.core.WaveletTransformLoss + mindflow.core.get_loss_metric + mindflow.core.batched_hessian + mindflow.core.batched_jacobian \ No newline at end of file diff --git a/docs/api_python/mindflow/mindflow.loss.rst b/docs/api_python/mindflow/mindflow.loss.rst deleted file mode 100644 index eb44e056a4bcc692843c9c7322152a02f992fda1..0000000000000000000000000000000000000000 --- a/docs/api_python/mindflow/mindflow.loss.rst +++ /dev/null @@ -1,12 +0,0 @@ -mindflow.loss -================== - -.. mscnplatformautosummary:: - :toctree: loss - :nosignatures: - :template: classtemplate.rst - - mindflow.loss.MTLWeightedLoss - mindflow.loss.RelativeRMSELoss - mindflow.loss.WaveletTransformLoss - mindflow.loss.get_loss_metric \ No newline at end of file diff --git a/docs/api_python/mindflow/mindflow.operators.rst b/docs/api_python/mindflow/mindflow.operators.rst deleted file mode 100644 index e44093e4bcdc75a4561be93cc527a503b3e561af..0000000000000000000000000000000000000000 --- a/docs/api_python/mindflow/mindflow.operators.rst +++ /dev/null @@ -1,10 +0,0 @@ -mindflow.operators -=================== - -.. mscnplatformautosummary:: - :toctree: operators - :nosignatures: - :template: classtemplate.rst - - mindflow.operators.batched_hessian - mindflow.operators.batched_jacobian \ No newline at end of file diff --git a/docs/api_python_en/mindflow/mindflow.common.rst b/docs/api_python_en/mindflow/mindflow.common.rst deleted file mode 100644 index e83f46661f0a85ccca9de613bb805963dafc8fe4..0000000000000000000000000000000000000000 --- a/docs/api_python_en/mindflow/mindflow.common.rst +++ /dev/null @@ -1,11 +0,0 @@ -mindflow.common -================== - -.. msplatformautosummary:: - :toctree: common - :nosignatures: - :template: classtemplate.rst - - mindflow.common.get_multi_step_lr - mindflow.common.get_poly_lr - mindflow.common.get_warmup_cosine_annealing_lr \ No newline at end of file diff --git a/docs/api_python_en/mindflow/mindflow.core.rst b/docs/api_python_en/mindflow/mindflow.core.rst new file mode 100644 index 0000000000000000000000000000000000000000..3d4d207df1fce039a7c2edc60d685c852261b353 --- /dev/null +++ b/docs/api_python_en/mindflow/mindflow.core.rst @@ -0,0 +1,17 @@ +mindflow.core +================== + +.. msplatformautosummary:: + :toctree: core + :nosignatures: + :template: classtemplate.rst + + mindflow.core.get_multi_step_lr + mindflow.core.get_poly_lr + mindflow.core.get_warmup_cosine_annealing_lr + mindflow.core.MTLWeightedLoss + mindflow.core.RelativeRMSELoss + mindflow.core.WaveletTransformLoss + mindflow.core.get_loss_metric + mindflow.core.batched_hessian + mindflow.core.batched_jacobian \ No newline at end of file diff --git a/docs/api_python_en/mindflow/mindflow.loss.rst b/docs/api_python_en/mindflow/mindflow.loss.rst deleted file mode 100644 index cb6abda150041f15f72132fb2aa02a4823b072ab..0000000000000000000000000000000000000000 --- a/docs/api_python_en/mindflow/mindflow.loss.rst +++ /dev/null @@ -1,12 +0,0 @@ -mindflow.loss -================== - -.. msplatformautosummary:: - :toctree: loss - :nosignatures: - :template: classtemplate.rst - - mindflow.loss.MTLWeightedLoss - mindflow.loss.RelativeRMSELoss - mindflow.loss.WaveletTransformLoss - mindflow.loss.get_loss_metric \ No newline at end of file diff --git a/docs/api_python_en/mindflow/mindflow.operators.rst b/docs/api_python_en/mindflow/mindflow.operators.rst deleted file mode 100644 index 937f97635dd3a0a8c8d307a82acf317476517920..0000000000000000000000000000000000000000 --- a/docs/api_python_en/mindflow/mindflow.operators.rst +++ /dev/null @@ -1,10 +0,0 @@ -mindflow.operators -=================== - -.. msplatformautosummary:: - :toctree: operators - :nosignatures: - :template: classtemplate.rst - - mindflow.operators.batched_hessian - mindflow.operators.batched_jacobian \ No newline at end of file