Browse Source

!8772 Updating notes for remaining .py file in ops/nn folder

From: @zhangz0911gm
Reviewed-by: 
Signed-off-by:
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
ac0b1aa960
5 changed files with 31 additions and 15 deletions
  1. +4
    -2
      mindspore/ops/operations/_inner_ops.py
  2. +6
    -3
      mindspore/ops/operations/array_ops.py
  3. +8
    -4
      mindspore/ops/operations/math_ops.py
  4. +5
    -2
      mindspore/ops/operations/nn_ops.py
  5. +8
    -4
      mindspore/ops/operations/random_ops.py

+ 4
- 2
mindspore/ops/operations/_inner_ops.py View File

@@ -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)
"""



+ 6
- 3
mindspore/ops/operations/array_ops.py View File

@@ -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],


+ 8
- 4
mindspore/ops/operations/math_ops.py View File

@@ -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)
"""



+ 5
- 2
mindspore/ops/operations/nn_ops.py View File

@@ -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])
"""



+ 8
- 4
mindspore/ops/operations/random_ops.py View File

@@ -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,)
"""



Loading…
Cancel
Save