diff --git a/docs/api/api_python/mindspore/mindspore.Tensor.rst b/docs/api/api_python/mindspore/mindspore.Tensor.rst index 9135bae8c59..d97437462fd 100644 --- a/docs/api/api_python/mindspore/mindspore.Tensor.rst +++ b/docs/api/api_python/mindspore/mindspore.Tensor.rst @@ -96,13 +96,25 @@ mindspore.Tensor NumPy的ndarray,该ndarray与Tensor共享内存地址。 + .. py:method:: assign_value(value) + + 将另一个Tensor的值赋给当前Tensor。 + + **参数:** + + - **value** (Tensor) - 用于赋值的Tensor。 + + **返回:** + + Tensor,赋值后的Tensor。 + .. py:method:: astype(dtype, copy=True) 将Tensor转为指定数据类型,可指定是否返回副本。 **参数:** - - **dtype** (Union[`mindspore.dtype` , str]) - 指定的Tensor数据类型,可以是: `mindspore.dtype.float32` 或 `float32` 的格式。默认值:`mindspore.dtype.float32` 。 + - **dtype** (Union[`mindspore.dtype` , `numpy.dtype` , str]) - 指定的Tensor数据类型,可以是: `mindspore.dtype.float32` , `numpy.float32` 或 `float32` 的格式。默认值:`mindspore.dtype.float32` 。 - **copy** (bool, optional) - 默认情况下,astype返回新拷贝的Tensor。如果该参数设为False,则返回输入Tensor而不是副本。默认值:True。 **返回:** diff --git a/docs/api/api_python/nn/mindspore.nn.ConfusionMatrixMetric.rst b/docs/api/api_python/nn/mindspore.nn.ConfusionMatrixMetric.rst index 25ae8e7c24f..0215955ae27 100644 --- a/docs/api/api_python/nn/mindspore.nn.ConfusionMatrixMetric.rst +++ b/docs/api/api_python/nn/mindspore.nn.ConfusionMatrixMetric.rst @@ -3,13 +3,13 @@ mindspore.nn.ConfusionMatrixMetric .. py:class:: mindspore.nn.ConfusionMatrixMetric(skip_channel=True, metric_name='sensitivity', calculation_method=False, decrease='mean') - 度量分类模型的性能矩阵是输出为二进制或多类的模型。 + 计算与混淆矩阵相关的度量。 - 从满量程Tensor计算混淆矩阵的相关性度量,并收集批次、类通道和迭代的平均值。 - 此函数支持计算以下描述的所有度量:参数metric_name中的度量名称。 + 该计算基于全尺度张量,并收集批处理平均值,类通道数和迭代数。 + 此函数支持计算参数metric_name中描述中列出的所有度量名称。 如果要使用混淆矩阵计算,如"PPV"、"TPR"、"TNR",请使用此类。 - 如果您只想计算混淆矩阵,请使用'mindspore.nn.ConfusionMatrix'。 + 如果只想计算混淆矩阵,请使用'mindspore.nn.ConfusionMatrix'。 **参数:** @@ -17,7 +17,7 @@ mindspore.nn.ConfusionMatrixMetric - **metric_name** (str) - 建议采用如下指标。当然,也可以为这些指标设置通用别名。 取值范围:["sensitivity", "specificity", "precision", "negative predictive value", "miss rate", "fall out", "false discovery rate", "false omission rate", "prevalence threshold", "threat score", "accuracy", "balanced accuracy", "f1 score", "matthews correlation coefficient", "fowlkes mallows index", "informedness", "markedness"]。 默认值:"sensitivity"。 - - **calculation_method** (bool) - 如果为True,则计算每个样品的度量值。如果为False,则累积所有样本的混淆矩阵。 + - **calculation_method** (bool) - 如果为True,则计算每个样本的度量值。如果为False,则累积所有样本的混淆矩阵。 对于分类任务, `calculation_method` 应为False。默认值:False。 - **decrease** (str) - 定义减少一批数据计算结果的模式。仅当 `calculation_method` 为True时,才生效。 取值范围:["none", "mean", "sum", "mean_batch", "sum_batch", "mean_channel", "sum_channel"]。默认值:"mean"。 diff --git a/docs/api/api_python/nn/mindspore.nn.CosineSimilarity.rst b/docs/api/api_python/nn/mindspore.nn.CosineSimilarity.rst index 49fbb9bac47..6f5f5d3e6c3 100644 --- a/docs/api/api_python/nn/mindspore.nn.CosineSimilarity.rst +++ b/docs/api/api_python/nn/mindspore.nn.CosineSimilarity.rst @@ -3,11 +3,11 @@ mindspore.nn.CosineSimilarity .. py:class:: mindspore.nn.CosineSimilarity(similarity='cosine', reduction='none', zero_diagonal=True) - 计算表示相似性。 + 计算余弦相似度。 **参数:** - - **similarity** (str) - "dot"或"cosine"。默认值:"cosine"。 + - **similarity** (str) - "dot"或"cosine"。"cosine"表示相似度计算逻辑, "dot"表示矩阵点乘矩阵计算逻辑。默认值:"cosine"。 - **reduction** (str) - "none"、"sum"或"mean"。默认值:"none"。 - **zero_diagonal** (bool) - 如果为True,则对角线将设置为零。默认值:True。 diff --git a/docs/api/api_python/nn/mindspore.nn.Dice.rst b/docs/api/api_python/nn/mindspore.nn.Dice.rst index f86ee0b4993..bd91e782f7c 100644 --- a/docs/api/api_python/nn/mindspore.nn.Dice.rst +++ b/docs/api/api_python/nn/mindspore.nn.Dice.rst @@ -5,7 +5,7 @@ mindspore.nn.Dice 集合相似性度量。 - 用于计算两个样本之间的相似性。当分割结果最好时,Dice系数的值为1,当分割结果最差时,Dice系数的值为0。Dice系数表示两个对象之间的面积与总面积的比率。 + 用于计算两个样本之间的相似性。当分割结果最好时,Dice系数的值为1,当分割结果最差时,Dice系数的值为0。Dice系数表示预测值与真实值交集同预测值和真实值并集之间的比值。 .. math:: dice = \frac{2 * (pred \bigcap true)}{pred \bigcup true} @@ -20,7 +20,7 @@ mindspore.nn.Dice .. py:method:: eval() - 计算混淆矩阵。 + 计算Dice系数。 **返回:** diff --git a/docs/api/api_python/nn/mindspore.nn.LazyAdam.rst b/docs/api/api_python/nn/mindspore.nn.LazyAdam.rst index 0163e35b3b1..1cc79271eac 100644 --- a/docs/api/api_python/nn/mindspore.nn.LazyAdam.rst +++ b/docs/api/api_python/nn/mindspore.nn.LazyAdam.rst @@ -23,7 +23,7 @@ mindspore.nn.LazyAdam .. note:: .. include:: mindspore.nn.optim_note_sparse.rst - 需要注意的是,梯度稀疏时该优化器只更新网络参数的当前的索引位置,稀疏行为不等同于Adam算法。 + 需要注意的是,梯度稀疏时该优化器只更新网络参数的当前的索引位置,稀疏行为不等同于Adam算法。如果想执行稀疏策略,那么需要把target设置为CPU。 .. include:: mindspore.nn.optim_note_weight_decay.rst diff --git a/docs/api/api_python/nn/mindspore.nn.auc.rst b/docs/api/api_python/nn/mindspore.nn.auc.rst index ee676448f40..c7ae43b285f 100644 --- a/docs/api/api_python/nn/mindspore.nn.auc.rst +++ b/docs/api/api_python/nn/mindspore.nn.auc.rst @@ -3,14 +3,14 @@ mindspore.nn.auc .. py:class:: mindspore.nn.auc(x, y, reorder=False) - 使用梯形规则计算曲线下面积AUC(Area Under the Curve,AUC)。这是一个一般函数,给定曲线上的点, + 使用梯形法则计算曲线下面积AUC(Area Under the Curve,AUC)。这是一个一般函数,给定曲线上的点, 用于计算ROC (Receiver Operating Curve, ROC) 曲线下的面积。 **参数:** - - **x** (Union[np.array, list]) - 从ROC曲线(fpr)来看,np.array具有假阳性率。如果是多类,则为np.array列表。Shape为 :math:`(N)` 。 - - **y** (Union[np.array, list]) - 从ROC曲线(tpr)来看,np.array具有假阳性率。如果是多类,则为np.array列表。Shape为 :math:`(N)` 。 + - **x** (Union[np.array, list]) - 从ROC曲线(False Positive Rate, FPR)来看,np.array具有假阳性率。如果是多类,则为np.array列表。Shape为 :math:`(N)` 。 + - **y** (Union[np.array, list]) - 从ROC曲线(True Positive Rate, TPR)来看,np.array具有假阳性率。如果是多类,则为np.array列表。Shape为 :math:`(N)` 。 **返回:** - area[bool],值为True。 + float,曲线下面积的值AUC。 diff --git a/mindspore/python/mindspore/common/tensor.py b/mindspore/python/mindspore/common/tensor.py index 6b40db11f14..3b7eca1b8c6 100644 --- a/mindspore/python/mindspore/common/tensor.py +++ b/mindspore/python/mindspore/common/tensor.py @@ -421,7 +421,15 @@ class Tensor(Tensor_): return Tensor(Tensor_.from_numpy(array)) def assign_value(self, value): - """Assign another tensor value to this tensor.""" + """ + Assign another tensor value to this tensor. + + Args: + value (Tensor): Tensor for assignment. + + Returns: + Tensor, Tensor that's been assigned. + """ self.assign_value_cpp(value) return self @@ -1032,7 +1040,7 @@ class Tensor(Tensor_): Return a copy of the tensor, cast to a specified type. Args: - dtype (Union[:class:`mindspore.dtype`, :class:`numpy.dtype`, str]): Designated tensor dtype, can be in + dtype (Union[:class:`mindspore.dtype`, numpy.dtype, str]): Designated tensor dtype, can be in format of :class:`mindspore.dtype.float32` or :class:`numpy.float32` or `float32`. copy (bool, optional): By default, astype always returns a newly allocated tensor. If this is set to false, the input tensor is returned instead diff --git a/mindspore/python/mindspore/numpy/array_creations.py b/mindspore/python/mindspore/numpy/array_creations.py index 9ffcdbcea1a..9da4d03ce1e 100644 --- a/mindspore/python/mindspore/numpy/array_creations.py +++ b/mindspore/python/mindspore/numpy/array_creations.py @@ -499,9 +499,9 @@ def rand(*shape, dtype=mstype.float32): def randint(minval, maxval=None, shape=None, dtype=mstype.int32): """ - Return random integers from minval (inclusive) to maxval (exclusive). Return random integers from the - discrete uniform distribution of the specified dtype in the “half-open” interval :math:`[minval, maxval)`. - If maxval is None (the default), the value range will be [0, minval), in this case, minval must be greater than 0. + Return random integers from minval (inclusive) to maxval (exclusive). Return random integers from the discrete + uniform distribution of the specified dtype in the “half-open” interval :math:`[minval, maxval)`. If maxval is + None (the default), the value range will be :math:`[0, minval)`, in this case, minval must be greater than 0. Args: minval(Union[int]): Start value of interval. The interval includes this value. When `maxval`