From 59c6ac872b039eef4ccfff2aa04386a6557f7dd1 Mon Sep 17 00:00:00 2001 From: liutongtong Date: Mon, 14 Mar 2022 12:38:38 +0800 Subject: [PATCH] fix chinese comments --- .../mindspore/mindspore.Parameter.rst | 7 ++++ docs/api/api_python/nn/mindspore.nn.Cell.rst | 41 ++++++++++++++++++- .../python/mindspore/nn/metrics/__init__.py | 6 +++ .../python/mindspore/nn/metrics/fbeta.py | 3 ++ .../python/mindspore/nn/metrics/metric.py | 6 +++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/docs/api/api_python/mindspore/mindspore.Parameter.rst b/docs/api/api_python/mindspore/mindspore.Parameter.rst index 7412e802600..dc9b38d04f1 100644 --- a/docs/api/api_python/mindspore/mindspore.Parameter.rst +++ b/docs/api/api_python/mindspore/mindspore.Parameter.rst @@ -79,6 +79,13 @@ - **ValueError** - `layout` 长度小于6。 - **TypeError** - `layout` 不是元组。 + .. py:method:: inited_param + :property: + + 用于调用 `init_data` 后,获取当前的Parameter。 + + 如果 `self` 是没有数据的Parameter,则默认返回为None;在调用 `init_data` 方法对Parameter初始化数据后,当前Parameter会被记录在此属性中。 + .. py:method:: layerwise_parallel :property: diff --git a/docs/api/api_python/nn/mindspore.nn.Cell.rst b/docs/api/api_python/nn/mindspore.nn.Cell.rst index 8e1fc3e3a04..30f19e8a26e 100644 --- a/docs/api/api_python/nn/mindspore.nn.Cell.rst +++ b/docs/api/api_python/nn/mindspore.nn.Cell.rst @@ -183,6 +183,21 @@ - **RuntimeError** – 如果参数不属于任何stage。 + .. py:method:: init_parameters_data(auto_parallel_mode=False) + + 初始化并替换Cell中所有的parameter的值。 + + .. note:: + 在调用`init_parameters_data`后,`trainable_params()` 或其他相似的接口可能返回不同的参数对象,不要保存这些结果。 + + **参数:** + + - **auto_parallel_mode** (bool) – 是否在自动并行模式下执行。 默认值:False。 + + **返回:** + + Dict[Parameter, Parameter], 返回一个原始参数和替换参数的字典。 + .. py:method:: insert_child_to_cell(child_name, child_cell) 将一个给定名称的子Cell添加到当前Cell。 @@ -369,6 +384,22 @@ 这个接口通常不需要显式调用。 + .. py:method:: run_construct(self, cast_inputs, kwargs) + + 运行construct方法。 + + .. note:: + 此函数将会在未来版本中弃用,不推荐使用此函数。 + + **参数:** + + - **cast_inputs** (tuple) – 输入的Cell对象。 + - **kwargs** (dict) – 关键字参数。 + + **返回:** + + Cell的输出。 + .. py:method:: set_auto_parallel() 将Cell设置为自动并行模式。 @@ -386,6 +417,14 @@ - **fusion_type** (int) – Parameter的 `comm_fusion` 属性的设置值。 - **recurse** (bool) – 是否递归地设置子Cell的可训练参数。默认值:True。 + .. py:method:: set_broadcast_flag(mode=True) + + 设置该Cell的参数广播模式。 + + **参数:** + + - **mode** (bool) – 指定当前模式是否进行参数广播。默认值:True。 + .. py:method:: set_data_parallel() 递归设置该Cell中的所有算子的并行策略为数据并行。 @@ -397,7 +436,7 @@ 指定输入/输出Tensor的分布策略,其余算子的策略推导得到。在PyNative模式下,可以利用此方法指定某个Cell以图模式进行分布式执行。 in_axes/out_axes需要为元组类型, 其中的每一个元素指定对应的输入/输出的Tensor分布策略,可参考: `mindspore.ops.Primitive.shard` 的描述,也可以设置为None,会默认以数据并行执行。 其余算子的并行策略由输入输出指定的策略推导得到。 - + .. note:: 需设置为PyNative模式,并且全自动并行(AUTO_PARALLEL),同时设置 `set_auto_parallel_context` 中的搜索模式(search mode)为"sharding_propagation",或半自动并行(SEMI_AUTO_PARALLEL)。 **参数:** diff --git a/mindspore/python/mindspore/nn/metrics/__init__.py b/mindspore/python/mindspore/nn/metrics/__init__.py index ef4678e5839..bd3a89dee34 100755 --- a/mindspore/python/mindspore/nn/metrics/__init__.py +++ b/mindspore/python/mindspore/nn/metrics/__init__.py @@ -99,6 +99,9 @@ def names(): Returns: List, the name list of metric methods. + + Supported Platforms: + ``Ascend`` ``GPU`` ``CPU`` """ return sorted(__factory__.keys()) @@ -116,6 +119,9 @@ def get_metric_fn(name, *args, **kwargs): Returns: Metric object, class instance of the metric method. + Supported Platforms: + ``Ascend`` ``GPU`` ``CPU`` + Examples: >>> from mindspore import nn >>> metric = nn.get_metric_fn('precision', eval_type='classification') diff --git a/mindspore/python/mindspore/nn/metrics/fbeta.py b/mindspore/python/mindspore/nn/metrics/fbeta.py index c4b53c57f37..a81819a11a7 100755 --- a/mindspore/python/mindspore/nn/metrics/fbeta.py +++ b/mindspore/python/mindspore/nn/metrics/fbeta.py @@ -143,6 +143,9 @@ class F1(Fbeta): .. math:: F_1=\frac{2\cdot true\_positive}{2\cdot true\_positive + false\_negative + false\_positive} + Supported Platforms: + ``Ascend`` ``GPU`` ``CPU`` + Examples: >>> import numpy as np >>> from mindspore import nn, Tensor diff --git a/mindspore/python/mindspore/nn/metrics/metric.py b/mindspore/python/mindspore/nn/metrics/metric.py index c653f117921..0017eedff38 100644 --- a/mindspore/python/mindspore/nn/metrics/metric.py +++ b/mindspore/python/mindspore/nn/metrics/metric.py @@ -55,6 +55,9 @@ def rearrange_inputs(func): Returns: Callable, used to exchange metadata between functions. + + Supported Platforms: + ``Ascend`` ``GPU`` ``CPU`` """ @functools.wraps(func) def wrapper(self, *inputs): @@ -74,6 +77,9 @@ class Metric(metaclass=ABCMeta): Never use this class directly, but instantiate one of its subclasses instead. For examples, :class:`mindspore.nn.MAE`, :class:`mindspore.nn.Recall` etc. + + Supported Platforms: + ``Ascend`` ``GPU`` ``CPU`` """ def __init__(self): self._indexes = None