megengine.functional.zeros

zeros(shape, *, dtype='float32', device=None)[source]

Returns a new tensor having a specified shape and filled with zeros.

Parameters

shape (int...) – the shape of the output tensor.

Keyword Arguments
  • dtype (Tensor.dtype, optional) – output tensor data type.

  • device (Tensor.device, optional) – device on which to place the created tensor.

Return type

Tensor

Returns

a tensor containing zeros.

Examples

>>> F.zeros((2, 3))
Tensor([[0. 0. 0.]
 [0. 0. 0.]], device=xpux:0)