MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / zeros_like

Function zeros_like

imperative/python/megengine/functional/tensor.py:392–407  ·  view source on GitHub ↗

r"""Returns a tensor filled with zeros with the same shape and data type as input tensor. Args: inp(Tensor): input tensor from which to derive the output tensor shape. Return: a tensor having the same shape as input tensor and filled with zeros. Examples: >>> x

(inp: Tensor)

Source from the content-addressed store, hash-verified

390
391
392def zeros_like(inp: Tensor) -> Tensor:
393 r"""Returns a tensor filled with zeros with the same shape and data type as input tensor.
394
395 Args:
396 inp(Tensor): input tensor from which to derive the output tensor shape.
397
398 Return:
399 a tensor having the same shape as input tensor and filled with zeros.
400
401 Examples:
402 >>> x = F.arange(6, dtype='int32').reshape(2, 3)
403 >>> F.zeros_like(x)
404 Tensor([[0 0 0]
405 [0 0 0]], dtype=int32, device=xpux:0)
406 """
407 return full_like(inp, 0.0)
408
409
410def ones_like(inp: Tensor) -> Tensor:

Callers 1

_canonical_maskFunction · 0.70

Calls 1

full_likeFunction · 0.85

Tested by

no test coverage detected