| @@ -208,33 +208,20 @@ def zeros(shape, dtype="float32", device=None) -> Tensor: | |||||
| 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: | ||||
| .. 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) | return full_like(inp, 0.0) | ||||