forked from mindspore-Ecosystem/mindspore
fix examples issues 3
This commit is contained in:
parent
35ccfc100f
commit
a9202e8d21
|
@ -364,6 +364,7 @@ def dot(x1, x2):
|
|||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> import numpy as np
|
||||
>>> import mindspore
|
||||
>>> from mindspore import Tensor, ops
|
||||
>>> input_x1 = Tensor(np.ones(shape=[2, 3]), mindspore.float32)
|
||||
|
|
|
@ -3800,8 +3800,6 @@ def broadcast_to(x, shape):
|
|||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> import mindspore.ops as ops
|
||||
>>> from mindspore import Tensor
|
||||
>>> shape = (2, 3)
|
||||
>>> x = Tensor(np.array([1, 2, 3]).astype(np.float32))
|
||||
>>> output = ops.broadcast_to(x, shape)
|
||||
|
|
|
@ -7057,10 +7057,11 @@ def cumprod(input, dim, dtype=None):
|
|||
Supported Platforms:
|
||||
``Ascend`` ``CPU`` ``GPU``
|
||||
|
||||
>>> x = Tensor(np.array([1, 2, 3], np.float32))
|
||||
>>> output = ops.cumprod(x, 0)
|
||||
>>> print(output)
|
||||
[1. 2. 6.]
|
||||
Examples:
|
||||
>>> x = Tensor(np.array([1, 2, 3], np.float32))
|
||||
>>> output = ops.cumprod(x, 0)
|
||||
>>> print(output)
|
||||
[1. 2. 6.]
|
||||
"""
|
||||
cumprod_op = _get_cache_prim(P.CumProd)()
|
||||
output = cumprod_op(input, dim)
|
||||
|
|
|
@ -62,6 +62,8 @@ class ReduceOp:
|
|||
|
||||
This example should be run with multiple devices.
|
||||
|
||||
>>> import numpy as np
|
||||
>>> import mindspore
|
||||
>>> from mindspore.communication import init
|
||||
>>> from mindspore import Tensor, ops, nn
|
||||
>>> from mindspore.ops import ReduceOp
|
||||
|
|
|
@ -315,8 +315,8 @@ class Custom(ops.PrimitiveWithInfer):
|
|||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> import mindspore.ops as ops
|
||||
>>> import numpy as np
|
||||
>>> from mindspore import Tensor, ops
|
||||
>>> from mindspore.ops import CustomRegOp, custom_info_register, DataType, kernel
|
||||
>>> from mindspore import dtype as mstype
|
||||
>>> from mindspore.nn import Cell
|
||||
|
|
|
@ -1153,7 +1153,7 @@ class Bucketize(Primitive):
|
|||
>>> class Bucketize(nn.Cell):
|
||||
... def __init__(self, boundaries):
|
||||
... super().__init__()
|
||||
... self.bucketize = op.Bucketize(boundaries=boundaries)
|
||||
... self.bucketize = ops.Bucketize(boundaries=boundaries)
|
||||
... def construct(self, input):
|
||||
... return self.bucketize(input)
|
||||
>>> input = Tensor(np.array([[3, 6, 9], [3, 6, 9]]).astype(np.int32))
|
||||
|
|
|
@ -8000,7 +8000,7 @@ class CTCLossV2(Primitive):
|
|||
>>> targets = Tensor(np.array([[0, 1]]), mstype.int32)
|
||||
>>> input_lengths = Tensor(np.array([2]), mstype.int32)
|
||||
>>> target_lengths = Tensor(np.array([1]), mstype.int32)
|
||||
>>> CTCLossV2 = op.CTCLossV2(blank=0, reduction='none', zero_infinity=False)
|
||||
>>> CTCLossV2 = ops.CTCLossV2(blank=0, reduction='none', zero_infinity=False)
|
||||
>>> neg_log_hood, log_alpha = CTCLossV2(
|
||||
... log_probs, targets, input_lengths, target_lengths)
|
||||
>>> print(neg_log_hood)
|
||||
|
|
Loading…
Reference in New Issue