forked from mindspore-Ecosystem/mindspore
!21000 fix the wrong output about operator CumSum and ReduceProd
Merge pull request !21000 from dinglinhe/code_docs_dlh_ms_I42FC7
This commit is contained in:
commit
aaa4af0481
|
@ -899,33 +899,33 @@ class ReduceProd(_Reduce):
|
|||
... [[7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9]]]), mindspore.float32)
|
||||
>>> output = op(x)
|
||||
>>> print(output)
|
||||
[[[1.]]]
|
||||
[[[2.2833798e+33]]]
|
||||
>>> print(output.shape)
|
||||
(1, 1, 1)
|
||||
>>> # case 2: Reduces a dimension along axis 0.
|
||||
>>> output = op(x, 0)
|
||||
>>> print(output)
|
||||
[[[1. 1. 1. 1. 1. 1.]
|
||||
[2. 2. 2. 2. 2. 2.]
|
||||
[3. 3. 3. 3. 3. 3.]]]
|
||||
[[[ 28. 28. 28. 28. 28. 28.]
|
||||
[ 80. 80. 80. 80. 80. 80.]
|
||||
[162. 162. 162. 162. 162. 162.]]]
|
||||
>>> # case 3: Reduces a dimension along axis 1.
|
||||
>>> output = op(x, 1)
|
||||
>>> print(output)
|
||||
[[[1. 1. 1. 1. 1. 1.]]
|
||||
[[4. 4. 4. 4. 4. 4.]]
|
||||
[[7. 7. 7. 7. 7. 7.]]]
|
||||
[[[ 6. 6. 6. 6. 6. 6.]]
|
||||
[[120. 120. 120. 120. 120. 120.]]
|
||||
[[504. 504. 504. 504. 504. 504.]]]
|
||||
>>> # case 4: Reduces a dimension along axis 2.
|
||||
>>> output = op(x, 2)
|
||||
>>> print(output)
|
||||
[[[1.]
|
||||
[2.]
|
||||
[3.]]
|
||||
[[4.]
|
||||
[5.]
|
||||
[6.]]
|
||||
[[7.]
|
||||
[8.]
|
||||
[9.]]]
|
||||
[[[1.00000e+00]
|
||||
[6.40000e+01]
|
||||
[7.29000e+02]]
|
||||
[[4.09600e+03]
|
||||
[1.56250e+04]
|
||||
[4.66560e+04]]
|
||||
[[1.17649e+05]
|
||||
[2.62144e+05]
|
||||
[5.31441e+05]]]
|
||||
"""
|
||||
|
||||
|
||||
|
@ -1201,7 +1201,7 @@ class CumSum(PrimitiveWithInfer):
|
|||
>>> # case 1: along the axis 0
|
||||
>>> y = cumsum(x, 0)
|
||||
>>> print(y)
|
||||
[[ 3. 7. 6. 10.]
|
||||
[[ 3. 4. 6. 10.]
|
||||
[ 4. 10. 13. 19.]
|
||||
[ 8. 13. 21. 26.]
|
||||
[ 9. 16. 28. 35.]]
|
||||
|
@ -1217,18 +1217,18 @@ class CumSum(PrimitiveWithInfer):
|
|||
>>> cumsum = ops.CumSum(exclusive=True)
|
||||
>>> y = cumsum(x, 1)
|
||||
>>> print(y)
|
||||
[[ 0. 3. 7. 23.]
|
||||
[ 0. 1. 7. 14.]
|
||||
[ 0. 4. 7. 15.]
|
||||
[ 0. 1. 4. 11.]]
|
||||
[[ 0. 3. 7. 13.]
|
||||
[ 0. 1. 7. 14.]
|
||||
[ 0. 4. 7. 15.]
|
||||
[ 0. 1. 4. 11.]]
|
||||
>>> # case 4: reverse = True
|
||||
>>> cumsum = ops.CumSum(reverse=True)
|
||||
>>> y = cumsum(x, 1)
|
||||
>>> print(y)
|
||||
[[ 23. 20. 16. 10.]
|
||||
[ 23. 22. 16. 9.]
|
||||
[ 22. 18. 15. 9.]
|
||||
[ 20. 19. 16. 9.]]
|
||||
[[23. 20. 16. 10.]
|
||||
[23. 22. 16. 9.]
|
||||
[22. 18. 15. 7.]
|
||||
[20. 19. 16. 9.]]
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
|
|
Loading…
Reference in New Issue