ones_like¶
- tripy.ones_like(input: Tensor, dtype: dtype | None = None) Tensor [source]¶
Creates a tensor with all elements set to 1 of the same shape as the input tensor.
- Parameters:
- Returns:
[dtype=T2] A tensor of the same shape as the input with all elements set to 1.
- Return type:
- TYPE CONSTRAINTS:
Example
1input = tp.zeros([2, 3], dtype=tp.float32) 2output = tp.ones_like(input)
>>> input tensor( [[0.0000, 0.0000, 0.0000], [0.0000, 0.0000, 0.0000]], dtype=float32, loc=gpu:0, shape=(2, 3)) >>> output tensor( [[1.0000, 1.0000, 1.0000], [1.0000, 1.0000, 1.0000]], dtype=float32, loc=gpu:0, shape=(2, 3))
See also