ones

dragon.vm.torch.ones(
  *size,
  **kwargs
)[source]

Return a tensor filled with ones.

\[\text{out} \leftarrow 1 \]
Parameters:
  • size (int...) – The size(s) indicating the out shape.
  • out (dragon.vm.torch.Tensor, optional) – The optional output tensor.
  • dtype (str, optional, default='float32') – The optional data type.
  • device (dragon.vm.torch.device, optional) – The optional device of returned tensor.
  • requires_grad (bool, optional, default=False) – True to record gradient for returned tensor.
Returns:

dragon.vm.torch.Tensor – The output tensor.