ones

tripy.ones(shape: tripy.types.ShapeLike, dtype: dtype = float32) Tensor[source]

Creates a Tensor of the specified shape and dtype with all elements set to 1.

Parameters:
  • shape (tripy.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:

Tensor

TYPE CONSTRAINTS:
Example
Example
1output = tp.ones([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

ones_like(), full()