Pytorch fundamentals
scalar=torch.tensor(7) # initialize a scalar tensor as 7 scalar.ndim # gives the number of dimension of scalarvector = torch.tensor([7, 7]) #creates the vector tensor vector.ndim #gets the number of dimension of vector
# Create a random tensor of size (224, 224, 3) random_image_size_tensor = torch.rand(size=(224, 224, 3)) random_image_size_tensor.shape, random_image_size_tensor.ndim
Last updated