
上QQ阅读APP看书,第一时间看更新
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])