>>> torch.ones(2, 3)
tensor([[ 1., 1., 1.],
[ 1., 1., 1.]])
torch.ones(*size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) → Tensor
参数 | 描述 |
---|---|
size (int…) | |
out (Tensor, optional) | |
dtype (torch.dtype, optional) | |
layout (torch.layout, optional) | |
device (torch.device, optional) | |
requires_grad (bool, optional) |
参考:
https://pytorch.org/docs/stable/generated/torch.ones.html#torch.ones