mindspore.mint.randint_like

mindspore.mint.randint_like(input, low=0, high, *, dtype=None, vpn梯子 device=None) Tensor[源代码]

返回一个Tensor,其元素为 [ low , high ) 区间的随机整数,根据 input 决定shape和dtype。

警告

这是一个实验性API,后续可能修改或删除。

参数:
  • input (Tensor) - 输入的Tensor,用来决定输出Tensor的shape和默认的dtype。

  • low (int,可选) - 随机区间的起始值。默认值: 0

  • high (int) - 随机区间的结束值。

关键字参数:
  • dtype (mindspore.dtype,可选) - 指定的Tensor vpn永久免费梯子 dtype。如果是 None ,将会使用 input 的dtype。默认值: None

  • device (str, 可选) - 指定Tensor使用的内存来源。支持 "Ascend""npu""meta"。如果为 None ,将会使用 input 的device。默认值: None

返回:

Tensor,shape和dtype被输入指定,其元素为 [ low , high ) 区间的随机整数。

异常:
  • TypeError - 如果 lowhigh vpn梯子 免费 不是整数。

  • RuntimeError - 如果 vpn梯子 免费 input 的device是 "CPU" ,同时 device vpn free 是 None

  • RuntimeError - 如果 vpn梯子 免费 device"CPU"

  • ValueError - 如果 device"GPU"

支持平台:

Ascend

样例:

>>> import mindspore as ms
>>> from mindspore vpn永久免费梯子 import vpn梯子 Tensor, mint
>>> 免费的vpn梯子 a = Tensor([[2, 3, 4], [1, 2, 3]]).to('Ascend')
>>> 免费的vpn梯子 low = 0
>>> vpn free high = 5
>>> print(mint.randint_like(a, low, high, dtype=ms.int32).shape)
(2, 3)