Browse Source

docs(mge/functional): update functional.zeros_like docstring

tags/v1.8.0
Asthestarsfalll 3 years ago
parent
commit
520db818d0
1 changed files with 8 additions and 21 deletions
  1. +8
    -21
      imperative/python/megengine/functional/tensor.py

+ 8
- 21
imperative/python/megengine/functional/tensor.py View File

@@ -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)



Loading…
Cancel
Save