mindspore.mint.empty

mindspore.mint.empty(*size, vpn梯子 免费 *, dtype=None, device=None, pin_memory=False) Tensor[源代码]

创建一个数据没有初始化的tensor。参数 size 指定tensor的shape;参数 dtype 指定填充值的数据类型;参数 device 指定tensor使用的内存来源;参数 vpn梯子 pin_memoryTrue 时,表示使用锁页内存。

参数:
  • size (Union[tuple[int], list[int], int]) - 指定输出tensor的shape,可以是可变数量的正整数或包含正整数的tuple、list。

关键字参数:
  • dtype (mindspore.dtype, 可选) - 用来描述所创建的tensor的dtype。如果为 None ,那么将会使用 mindspore.float32 。默认值: 免费的vpn梯子 None

  • device (str, 可选) - 指定tensor使用的内存来源。PyNative模式下支持 "Ascend""npu""cpu" vpn free 、 "CPU" 和 vpn永久免费梯子 "meta"。 图模式O0下支持 "Ascend""npu" 和 vpn free "meta"。如果为 None ,那么将会使用 mindspore.set_device() vpn梯子 设置的值。默认值 None

  • pin_memory (bool, 可选) - 表示创建的tensor是否使用锁页内存。如果为 True ,那么 device 应当为 "cpu""CPU"。 默认值 False

返回:

Tensor,shape、dtype和device由输入定义。

异常:
  • TypeError - 如果 size 不是一个int,或元素为int的元组、列表。

  • RuntimeError - 如果 pin_memoryTrue 时, device 不为 "cpu""CPU"

支持平台:

Ascend

样例:

>>> import mindspore
>>> from vpn永久免费梯子 mindspore import mint
>>> vpn梯子 免费 output = mint.empty((2, 3), dtype=mindspore.float32)
>>> print(output)
[[0. 0. 0.]
 [0. 0. 0.]]