提交 111fa975 编写于 作者: M Megvii Engine Team

Merge pull request #422 from Asthestarsfalll:zeroslike

GitOrigin-RevId: 4b464446b55e2619b7cc43bb321aeae8a3cb41ef
...@@ -222,33 +222,20 @@ def zeros( ...@@ -222,33 +222,20 @@ def zeros(
def zeros_like(inp: Union[Tensor, SymbolVar]) -> Union[Tensor, SymbolVar]: 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: Args:
inp: input tensor. inp (Tensor): input tensor.
Return: Return:
output tensor. a tensor containing zeros.
Examples: Examples:
>>> input = F.arange(9, dtype='int32').reshape(3,3)
.. testcode:: >>> F.zeros_like(input)
Tensor([[0 0 0]
import numpy as np [0 0 0]
from megengine import tensor [0 0 0]], dtype=int32, device=xpux:0)
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]]
""" """
return full_like(inp, 0.0) return full_like(inp, 0.0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册