- Deep Learning with PyTorch
- Vishnu Subramanian
- 56字
- 2021-06-24 19:16:23
Scalar (0-D tensors)
A tensor containing only one element is called a scalar. It will generally be of type FloatTensor or LongTensor. At the time of writing, PyTorch does not have a special tensor with zero dimensions. So, we use a one-dimension tensor with one element, as follows:
x = torch.rand(10)
x.size()
Output - torch.Size([10])