提交 b7fe6a27 编写于 作者: Asthestarsfalll's avatar Asthestarsfalll

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

上级 051a6055
......@@ -240,32 +240,19 @@ def zeros_like(inp: Union[Tensor, SymbolVar]) -> Union[Tensor, SymbolVar]:
def ones_like(inp: Union[Tensor, SymbolVar]) -> Union[Tensor, SymbolVar]:
r"""Returns a ones tensor with the same shape as input tensor.
r"""Returns a tensor filled with ones with the same shape and data type as input tensor.
Args:
inp: input tensor.
inp (Tensor): input tensor.
Return:
output tensor.
a tensor containing ones.
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.ones_like(inp)
print(out.numpy())
Outputs:
.. testoutput::
[[1 1 1]
[1 1 1]]
>>> input = F.arange(6, dtype='int32').reshape(2,3)
>>> F.ones_like(input)
Tensor([[1 1 1]
[1 1 1]], dtype=int32, device=xpux:0)
"""
return full_like(inp, 1.0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册