From 520db818d09ebe9094b38289c7f11486deaa9311 Mon Sep 17 00:00:00 2001 From: Asthestarsfalll <1186454801@qq.com> Date: Mon, 27 Dec 2021 19:09:09 +0800 Subject: [PATCH] docs(mge/functional): update functional.zeros_like docstring --- .../python/megengine/functional/tensor.py | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/imperative/python/megengine/functional/tensor.py b/imperative/python/megengine/functional/tensor.py index e8ff2e6a2..87555473d 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) -- GitLab