diff --git a/imperative/python/megengine/functional/tensor.py b/imperative/python/megengine/functional/tensor.py index e8ff2e6a2da9addf02860e967aeaa3daae2c5dc5..87555473d4b8280777278a7b8b9fed1698da8ef8 100755 --- a/imperative/python/megengine/functional/tensor.py +++ b/imperative/python/megengine/functional/tensor.py @@ -208,33 +208,20 @@ def zeros(shape, dtype="float32", device=None) -> Tensor: def zeros_like(inp: Union[Tensor, SymbolVar]) -> Union[Tensor, SymbolVar]: - r"""Returns a zero tensor with the same shape as input tensor. + r"""Returns a tensor filled with zeros with the same shape and data type as input tensor. Args: - inp: input tensor. + inp (Tensor): input tensor. Return: - output tensor. + a tensor containing zeros. Examples: - - .. testcode:: - - import numpy as np - from megengine import tensor - import megengine.functional as F - - inp = tensor(np.arange(1, 7, dtype=np.int32).reshape(2,3)) - out = F.zeros_like(inp) - print(out.numpy()) - - Outputs: - - .. testoutput:: - - [[0 0 0] - [0 0 0]] - + >>> input = F.arange(9, dtype='int32').reshape(3,3) + >>> F.ones_like(input) + Tensor([[0 0 0] + [0 0 0] + [0 0 0]], dtype=int32, device=xpux:0) """ return full_like(inp, 0.0)