| @@ -371,7 +371,7 @@ class AvgPool1d(_PoolNd): | |||||
| self.squeeze = P.Squeeze(2) | self.squeeze = P.Squeeze(2) | ||||
| def construct(self, x): | def construct(self, x): | ||||
| _shape_check(self.shape(x)) | |||||
| x = F.depend(x, _shape_check(self.shape(x))) | |||||
| batch, channel, width = self.shape(x) | batch, channel, width = self.shape(x) | ||||
| if width == self.kernel_size[1]: | if width == self.kernel_size[1]: | ||||
| x = self.reduce_mean(x, 2) | x = self.reduce_mean(x, 2) | ||||
| @@ -82,7 +82,8 @@ from .nn_ops import (LSTM, SGD, Adam, FusedSparseAdam, FusedSparseLazyAdam, Appl | |||||
| ApplyRMSProp, ApplyCenteredRMSProp, BasicLSTMCell, InTopK, UniformCandidateSampler) | ApplyRMSProp, ApplyCenteredRMSProp, BasicLSTMCell, InTopK, UniformCandidateSampler) | ||||
| from . import _quant_ops | from . import _quant_ops | ||||
| from ._quant_ops import * | from ._quant_ops import * | ||||
| from .other_ops import (Assign, InplaceAssign, IOU, BoundingBoxDecode, BoundingBoxEncode, PopulationCount, | |||||
| from .other_ops import (Assign, InplaceAssign, IOU, BoundingBoxDecode, BoundingBoxEncode, | |||||
| ConfusionMatrix, PopulationCount, | |||||
| CheckValid, MakeRefKey, Partial, Depend, identity, CheckBprop, Push, Pull) | CheckValid, MakeRefKey, Partial, Depend, identity, CheckBprop, Push, Pull) | ||||
| from ._thor_ops import (CusBatchMatMul, CusCholeskyTrsm, CusFusedAbsMax1, CusImg2Col, CusMatMulCubeDenseLeft, | from ._thor_ops import (CusBatchMatMul, CusCholeskyTrsm, CusFusedAbsMax1, CusImg2Col, CusMatMulCubeDenseLeft, | ||||
| CusMatMulCubeFraczRightMul, CusMatMulCube, CusMatrixCombine, CusTranspose02314, | CusMatMulCubeFraczRightMul, CusMatMulCube, CusMatrixCombine, CusTranspose02314, | ||||
| @@ -289,6 +290,7 @@ __all__ = [ | |||||
| 'DepthwiseConv2dNative', | 'DepthwiseConv2dNative', | ||||
| 'UnsortedSegmentSum', | 'UnsortedSegmentSum', | ||||
| 'UnsortedSegmentMin', | 'UnsortedSegmentMin', | ||||
| 'UnsortedSegmentMax', | |||||
| 'UnsortedSegmentProd', | 'UnsortedSegmentProd', | ||||
| "AllGather", | "AllGather", | ||||
| "AllReduce", | "AllReduce", | ||||
| @@ -377,6 +379,7 @@ __all__ = [ | |||||
| "UniformCandidateSampler", | "UniformCandidateSampler", | ||||
| "LRN", | "LRN", | ||||
| "Mod", | "Mod", | ||||
| "ConfusionMatrix", | |||||
| "PopulationCount", | "PopulationCount", | ||||
| "ParallelConcat", | "ParallelConcat", | ||||
| "Push", | "Push", | ||||
| @@ -2104,18 +2104,19 @@ class Slice(PrimitiveWithInfer): | |||||
| Slices a tensor in the specified shape. | Slices a tensor in the specified shape. | ||||
| Inputs: | Inputs: | ||||
| x (Tensor): The target tensor. | |||||
| begin (tuple): The beginning of the slice. Only constant value is allowed. | |||||
| size (tuple): The size of the slice. Only constant value is allowed. | |||||
| - **x** (Tensor): The target tensor. | |||||
| - **begin** (tuple): The beginning of the slice. Only constant value is allowed. | |||||
| - **size** (tuple): The size of the slice. Only constant value is allowed. | |||||
| Returns: | |||||
| Tensor. | |||||
| Outputs: | |||||
| Tensor, the shape is : input `size`, the data type is the same as input `x`. | |||||
| Examples: | Examples: | ||||
| >>> data = Tensor(np.array([[[1, 1, 1], [2, 2, 2]], | >>> data = Tensor(np.array([[[1, 1, 1], [2, 2, 2]], | ||||
| >>> [[3, 3, 3], [4, 4, 4]], | >>> [[3, 3, 3], [4, 4, 4]], | ||||
| >>> [[5, 5, 5], [6, 6, 6]]]).astype(np.int32)) | >>> [[5, 5, 5], [6, 6, 6]]]).astype(np.int32)) | ||||
| >>> type = P.Slice()(data, (1, 0, 0), (1, 1, 3)) | >>> type = P.Slice()(data, (1, 0, 0), (1, 1, 3)) | ||||
| >>> print(type) | |||||
| [[[3 3 3]]] | [[[3 3 3]]] | ||||
| """ | """ | ||||
| @@ -5412,7 +5412,7 @@ class Dropout(PrimitiveWithInfer): | |||||
| Args: | Args: | ||||
| keep_prob (float): The keep rate, between 0 and 1, e.g. keep_prob = 0.9, | keep_prob (float): The keep rate, between 0 and 1, e.g. keep_prob = 0.9, | ||||
| means dropping out 10% of input units. | |||||
| means dropping out 10% of input units. | |||||
| Inputs: | Inputs: | ||||
| - **input** (Tensor) - The input tensor. | - **input** (Tensor) - The input tensor. | ||||
| @@ -5426,9 +5426,9 @@ class Dropout(PrimitiveWithInfer): | |||||
| >>> x = Tensor((20, 16, 50, 50), mindspore.float32) | >>> x = Tensor((20, 16, 50, 50), mindspore.float32) | ||||
| >>> output, mask = dropout(x) | >>> output, mask = dropout(x) | ||||
| >>> print(output) | >>> print(output) | ||||
| [ 0. 32. 0. 0.] | |||||
| [0. 32. 0. 0.] | |||||
| >>> print(mask) | >>> print(mask) | ||||
| [0. 1. 0. 0.] | |||||
| [0. 1. 0. 0.] | |||||
| """ | """ | ||||
| @prim_attr_register | @prim_attr_register | ||||
| @@ -492,7 +492,12 @@ class ConfusionMatrix(PrimitiveWithInfer): | |||||
| >>> confusion_matrix = P.ConfusionMatrix(4) | >>> confusion_matrix = P.ConfusionMatrix(4) | ||||
| >>> labels = Tensor([0, 1, 1, 3], mindspore.int32) | >>> labels = Tensor([0, 1, 1, 3], mindspore.int32) | ||||
| >>> predictions = Tensor([1, 2, 1, 3], mindspore.int32) | >>> predictions = Tensor([1, 2, 1, 3], mindspore.int32) | ||||
| >>> confusion_matrix(labels, predictions) | |||||
| >>> output = confusion_matrix(labels, predictions) | |||||
| >>> print(output) | |||||
| [[0 1 0 0 | |||||
| [0 1 1 0] | |||||
| [0 0 0 0] | |||||
| [0 0 0 1]] | |||||
| """ | """ | ||||
| @prim_attr_register | @prim_attr_register | ||||