fix examples issues 3

This commit is contained in:
luojianing 2022-11-29 20:23:06 +08:00
parent 35ccfc100f
commit a9202e8d21
7 changed files with 11 additions and 9 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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