ones

dragon.ones(
  shape,
  dtype='float32',
  **kwargs
)[source]

Return a tensor filled with ones.

\[y \leftarrow 1 \]
x = dragon.ones(shape=(2, 3), dtype='float32')
Parameters:
  • shape (Sequence[Union[int, dragon.Tensor]]) – The shape of the tensor.
  • dtype (str, optional, default='float32') – The optional data type.
Returns:

dragon.Tensor – The output tensor.