diff --git a/mindspore/ops/operations/_inner_ops.py b/mindspore/ops/operations/_inner_ops.py index 3c79d790e2..1f8da40198 100644 --- a/mindspore/ops/operations/_inner_ops.py +++ b/mindspore/ops/operations/_inner_ops.py @@ -132,7 +132,8 @@ class Range(PrimitiveWithInfer): Examples: >>> range = P.Range(1.0, 8.0, 2.0) >>> x = Tensor(np.array([1, 2, 3, 2]), mindspore.int32) - >>> range(x) + >>> output = range(x) + >>> print(output) [3, 5, 7, 5] """ @@ -524,7 +525,8 @@ class DynamicGRUV2(PrimitiveWithInfer): >>> init_h = Tensor(np.random.rand(8, 16).astype(np.float16)) >>> dynamic_gru_v2 = P.DynamicGRUV2() >>> output = dynamic_gru_v2(x, weight_i, weight_h, bias_i, bias_h, None, init_h) - >>> output[0].shape + >>> result = output[0].shape + >>> print(result) (2, 8, 16) """ diff --git a/mindspore/ops/operations/array_ops.py b/mindspore/ops/operations/array_ops.py index cf7d48bbe0..9a992d4222 100644 --- a/mindspore/ops/operations/array_ops.py +++ b/mindspore/ops/operations/array_ops.py @@ -1136,7 +1136,8 @@ class Ones(PrimitiveWithInfer): Examples: >>> ones = P.Ones() - >>> Ones((2, 2), mindspore.float32) + >>> output = Ones((2, 2), mindspore.float32) + >>> print(output) [[1.0, 1.0], [1.0, 1.0]] """ @@ -1179,7 +1180,8 @@ class Zeros(PrimitiveWithInfer): Examples: >>> zeros = P.Zeros() - >>> Zeros((2, 2), mindspore.float32) + >>> output = Zeros((2, 2), mindspore.float32) + >>> print(output) [[0.0, 0.0], [0.0, 0.0]] @@ -2751,7 +2753,8 @@ class Diag(PrimitiveWithInfer): Examples: >>> input_x = Tensor([1, 2, 3, 4]) >>> diag = P.Diag() - >>> diag(input_x) + >>> output = diag(input_x) + >>> print(output) [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], diff --git a/mindspore/ops/operations/math_ops.py b/mindspore/ops/operations/math_ops.py index 860e869261..3d9f390b4a 100644 --- a/mindspore/ops/operations/math_ops.py +++ b/mindspore/ops/operations/math_ops.py @@ -360,7 +360,8 @@ class ReduceMean(_Reduce): >>> input_x = Tensor(np.random.randn(3, 4, 5, 6).astype(np.float32)) >>> op = P.ReduceMean(keep_dims=True) >>> output = op(input_x, 1) - >>> output.shape + >>> result = output.shape + >>> print(result) (3, 1, 5, 6) """ @@ -525,7 +526,8 @@ class ReduceMax(_Reduce): >>> input_x = Tensor(np.random.randn(3, 4, 5, 6).astype(np.float32)) >>> op = P.ReduceMax(keep_dims=True) >>> output = op(input_x, 1) - >>> output.shape + >>> result = output.shape + >>> print(result) (3, 1, 5, 6) """ @@ -572,7 +574,8 @@ class ReduceMin(_Reduce): >>> input_x = Tensor(np.random.randn(3, 4, 5, 6).astype(np.float32)) >>> op = P.ReduceMin(keep_dims=True) >>> output = op(input_x, 1) - >>> output.shape + >>> result = output.shape + >>> print(result) (3, 1, 5, 6) """ @@ -610,7 +613,8 @@ class ReduceProd(_Reduce): >>> input_x = Tensor(np.random.randn(3, 4, 5, 6).astype(np.float32)) >>> op = P.ReduceProd(keep_dims=True) >>> output = op(input_x, 1) - >>> output.shape + >>> reuslt = output.shape + >>> print(result) (3, 1, 5, 6) """ diff --git a/mindspore/ops/operations/nn_ops.py b/mindspore/ops/operations/nn_ops.py index f51e539be0..7c392bc2a9 100644 --- a/mindspore/ops/operations/nn_ops.py +++ b/mindspore/ops/operations/nn_ops.py @@ -703,7 +703,8 @@ class FusedBatchNorm(Primitive): >>> input_x = Tensor(np.ones([128, 64, 32, 64]), mindspore.float32) >>> net = FusedBatchNormNet() >>> output = net(input_x) - >>> output[0].shape + >>> result = output[0].shape + >>> print(result) (128, 64, 32, 64) """ __mindspore_signature__ = ( @@ -799,7 +800,8 @@ class FusedBatchNormEx(PrimitiveWithInfer): >>> input_x = Tensor(np.ones([128, 64, 32, 64]), mindspore.float32) >>> net = FusedBatchNormExNet() >>> output = net(input_x) - >>> output[0].shape + >>> result = output[0].shape + >>> print(result) (128, 64, 32, 64) """ __mindspore_signature__ = ( @@ -1881,6 +1883,7 @@ class TopK(PrimitiveWithInfer): >>> input_x = Tensor([1, 2, 3, 4, 5], mindspore.float16) >>> k = 3 >>> values, indices = topk(input_x, k) + >>> print((values, indices)) ([5.0, 4.0, 3.0], [4, 3, 2]) """ diff --git a/mindspore/ops/operations/random_ops.py b/mindspore/ops/operations/random_ops.py index c641b2edc5..04d4ff977e 100644 --- a/mindspore/ops/operations/random_ops.py +++ b/mindspore/ops/operations/random_ops.py @@ -41,7 +41,8 @@ class StandardNormal(PrimitiveWithInfer): >>> shape = (4, 16) >>> stdnormal = P.StandardNormal(seed=2) >>> output = stdnormal(shape) - >>> output.shape + >>> result = output.shape + >>> print(result) (4, 16) """ @@ -91,7 +92,8 @@ class StandardLaplace(PrimitiveWithInfer): >>> shape = (4, 16) >>> stdlaplace = P.StandardLaplace(seed=2) >>> output = stdlaplace(shape) - >>> output.shape + >>> result = output.shape + >>> print(result) (4, 16) """ @@ -375,9 +377,11 @@ class RandomChoiceWithMask(PrimitiveWithInfer): >>> rnd_choice_mask = P.RandomChoiceWithMask() >>> input_x = Tensor(np.ones(shape=[240000, 4]).astype(np.bool)) >>> output_y, output_mask = rnd_choice_mask(input_x) - >>> output_y.shape + >>> result = output_y.shape + >>> print(result) (256, 2) - >>> output_mask.shape + >>> result = output_mask.shape + >>> print(reuslt) (256,) """