PyTorch - Basic
December 27, 2024Less than 1 minute
Vectors
Vector is considered to be array of numbers which is either continuous or discrete and the space which consists of vectors is called as vector space. The space dimensions of vectors can be either finite or infinite but it has been observed that machine learning and data science problems deal with fixed length vectors.
temp = torch.FloatTensor([23,24,24.5,26,27.2,23.0])
temp.size()
Scalars
Scalars are termed to have zero dimensions containing only one value. When it comes to PyTorch, it does not include a special tensor with zero dimensions; hence the declaration will be made as follows −
x = torch.rand(10)
x.size()
Output - torch.Size([10])