!20350 update the result of example for Split, Tril, Triu and ApplyFtrl.
Merge pull request !20350 from wangshuide/code_docs_wsd_master_new
This commit is contained in:
commit
7352110561
|
@ -1013,10 +1013,10 @@ class Tril(Cell):
|
|||
>>> tril = nn.Tril()
|
||||
>>> result = tril(x)
|
||||
>>> print(result)
|
||||
[[ 1, 0, 0, 0],
|
||||
[ 5, 6, 0, 0],
|
||||
[10, 11, 12, 0],
|
||||
[14, 15, 16, 17]]))
|
||||
[[ 1 0 0 0]
|
||||
[ 5 6 0 0]
|
||||
[10 11 12 0]
|
||||
[14 15 16 17]]
|
||||
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
||||
... [ 5, 6, 7, 8],
|
||||
... [10, 11, 12, 13],
|
||||
|
@ -1024,10 +1024,10 @@ class Tril(Cell):
|
|||
>>> tril = nn.Tril()
|
||||
>>> result = tril(x, 1)
|
||||
>>> print(result)
|
||||
[[ 1, 2, 0, 0],
|
||||
[ 5, 6, 7, 0],
|
||||
[10, 11, 12, 13],
|
||||
[14, 15, 16, 17]]))
|
||||
[[ 1 2 0 0]
|
||||
[ 5 6 7 0]
|
||||
[10 11 12 13]
|
||||
[14 15 16 17]]
|
||||
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
||||
... [ 5, 6, 7, 8],
|
||||
... [10, 11, 12, 13],
|
||||
|
@ -1035,10 +1035,10 @@ class Tril(Cell):
|
|||
>>> tril = nn.Tril()
|
||||
>>> result = tril(x, 2)
|
||||
>>> print(result)
|
||||
[[ 1, 2, 3, 0],
|
||||
[ 5, 6, 7, 8],
|
||||
[10, 11, 12, 13],
|
||||
[14, 15, 16, 17]]))
|
||||
[[ 1 2 3 0]
|
||||
[ 5 6 7 8]
|
||||
[10 11 12 13]
|
||||
[14 15 16 17]]
|
||||
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
||||
... [ 5, 6, 7, 8],
|
||||
... [10, 11, 12, 13],
|
||||
|
@ -1046,10 +1046,10 @@ class Tril(Cell):
|
|||
>>> tril = nn.Tril()
|
||||
>>> result = tril(x, -1)
|
||||
>>> print(result)
|
||||
[[ 0, 0, 0, 0],
|
||||
[ 5, 0, 0, 0],
|
||||
[10, 11, 0, 0],
|
||||
[14, 15, 16, 0]]))
|
||||
[[ 0 0 0 0]
|
||||
[ 5 0 0 0]
|
||||
[10 11 0 0]
|
||||
[14 15 16 0]]
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
@ -1100,10 +1100,10 @@ class Triu(Cell):
|
|||
>>> triu = nn.Triu()
|
||||
>>> result = triu(x)
|
||||
>>> print(result)
|
||||
[[ 1, 2, 3, 4],
|
||||
[ 0, 6, 7, 8],
|
||||
[ 0, 0, 12, 13],
|
||||
[ 0, 0, 0, 17]]
|
||||
[[ 1 2 3 4]
|
||||
[ 0 6 7 8]
|
||||
[ 0 0 12 13]
|
||||
[ 0 0 0 17]]
|
||||
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
||||
... [ 5, 6, 7, 8],
|
||||
... [10, 11, 12, 13],
|
||||
|
@ -1111,10 +1111,10 @@ class Triu(Cell):
|
|||
>>> triu = nn.Triu()
|
||||
>>> result = triu(x, 1)
|
||||
>>> print(result)
|
||||
[[ 0, 2, 3, 4],
|
||||
[ 0, 0, 7, 8],
|
||||
[ 0, 0, 0, 13],
|
||||
[ 0, 0, 0, 0]]
|
||||
[[ 0 2 3 4]
|
||||
[ 0 0 7 8]
|
||||
[ 0 0 0 13]
|
||||
[ 0 0 0 0]]
|
||||
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
||||
... [ 5, 6, 7, 8],
|
||||
... [10, 11, 12, 13],
|
||||
|
@ -1122,10 +1122,10 @@ class Triu(Cell):
|
|||
>>> triu = nn.Triu()
|
||||
>>> result = triu(x, 2)
|
||||
>>> print(result)
|
||||
[[ 0, 0, 3, 4],
|
||||
[ 0, 0, 0, 8],
|
||||
[ 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0]]
|
||||
[[ 0 0 3 4]
|
||||
[ 0 0 0 8]
|
||||
[ 0 0 0 0]
|
||||
[ 0 0 0 0]]
|
||||
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
||||
... [ 5, 6, 7, 8],
|
||||
... [10, 11, 12, 13],
|
||||
|
@ -1133,10 +1133,10 @@ class Triu(Cell):
|
|||
>>> triu = nn.Triu()
|
||||
>>> result = triu(x, -1)
|
||||
>>> print(result)
|
||||
[[ 1, 2, 3, 4],
|
||||
[ 5, 6, 7, 8],
|
||||
[ 0, 11, 12, 13],
|
||||
[ 0, 0, 16, 17]]
|
||||
[[ 1 2 3 4]
|
||||
[ 5 6 7 8]
|
||||
[ 0 11 12 13]
|
||||
[ 0 0 16 17]]
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
|
|
@ -1690,11 +1690,11 @@ def vander(x, N=None, increasing=False):
|
|||
Examples:
|
||||
>>> import mindspore.numpy as np
|
||||
>>> print(np.vander([1., 2., 3., 4., 5.]))
|
||||
[[ 1 1 1 1 1]
|
||||
[ 16 8 4 2 1]
|
||||
[ 81 27 9 3 1]
|
||||
[256 64 16 4 1]
|
||||
[625 125 25 5 1]]
|
||||
[[ 1. 1. 1. 1. 1.]
|
||||
[ 16. 8. 4. 2. 1.]
|
||||
[ 81. 27. 9. 3. 1.]
|
||||
[256. 64. 16. 4. 1.]
|
||||
[625. 125. 25. 5. 1.]]
|
||||
"""
|
||||
if isinstance(x, (list, tuple)):
|
||||
x = asarray_const(x)
|
||||
|
|
|
@ -1036,7 +1036,7 @@ class Split(PrimitiveWithCheck):
|
|||
>>> x = Tensor(np.array([[1, 1, 1, 1], [2, 2, 2, 2]]), mindspore.int32)
|
||||
>>> print(x)
|
||||
[[1 1 1 1]
|
||||
[2 2 2 2]])
|
||||
[2 2 2 2]]
|
||||
>>> output = split(x)
|
||||
>>> print(output)
|
||||
(Tensor(shape=[2, 2], dtype=Int32, value=
|
||||
|
|
|
@ -174,8 +174,8 @@ class AdaptiveAvgPool2D(PrimitiveWithInfer):
|
|||
Examples:
|
||||
>>> # case 1: output_size=(None, 2)
|
||||
>>> input_x = Tensor(np.array([[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]],
|
||||
>>> [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]],
|
||||
>>> [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]]), mindspore.float32)
|
||||
... [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]],
|
||||
... [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]]), mindspore.float32)
|
||||
>>> adaptive_avg_pool_2d = ops.AdaptiveAvgPool2D((None, 2))
|
||||
>>> output = adaptive_avg_pool_2d(input_x)
|
||||
>>> print(output)
|
||||
|
@ -6748,8 +6748,8 @@ class ApplyFtrl(PrimitiveWithInfer):
|
|||
>>> input_x = Tensor(np.array([[0.3, 0.7], [0.1, 0.8]]).astype(np.float32))
|
||||
>>> output = net(input_x)
|
||||
>>> print(net.var.asnumpy())
|
||||
[[ 0.0390525, 0.11492836]
|
||||
[ 0.00066425, 0.15075898]]
|
||||
[[ 0.0390525 0.11492836]
|
||||
[ 0.00066425 0.15075898]]
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
|
|
Loading…
Reference in New Issue