zeros_like

tripy.zeros_like(input: Tensor, dtype: dtype | None = None) Tensor[source]

Creates a Tensor with all elements set to 0 of the same shape as the input tensor.

Parameters:
  • input (Tensor) – [dtype=T1] The input tensor.

  • dtype (dtype | None) – [dtype=T2] Datatype of elements. If set to None, the datatype of the input tensor is used.

Returns:

[dtype=T2] A tensor of the same shape as the input with all elements set to 0.

Return type:

Tensor

TYPE CONSTRAINTS:
Example
Example
1input = tp.iota([2, 3], dtype=tp.float32)
2output = tp.zeros_like(input)
>>> input
tensor(
    [[0.0000, 0.0000, 0.0000],
     [1.0000, 1.0000, 1.0000]], 
    dtype=float32, loc=gpu:0, shape=(2, 3))
>>> output
tensor(
    [[0.0000, 0.0000, 0.0000],
     [0.0000, 0.0000, 0.0000]], 
    dtype=float32, loc=gpu:0, shape=(2, 3))

See also

zeros(), full_like()