ones¶
- nvtripy.ones(shape: nvtripy.types.ShapeLike, dtype: dtype = float32) Tensor [source]¶
Creates a Tensor of the specified shape and dtype with all elements set to 1.
- Parameters:
shape (nvtripy.types.ShapeLike) – The desired shape of the tensor.
dtype (dtype) – [dtype=T1] Datatype of elements.
- Returns:
[dtype=T1] A tensor of shape
shape
with all elements set to 1.- Return type:
Example
1output = tp.ones([2, 3])
Local Variables¶>>> output tensor( [[1, 1, 1], [1, 1, 1]], dtype=float32, loc=gpu:0, shape=(2, 3))
See also