Propiedades de los tensores frente a las matrices

a = torch.tensor([[1, 2, 3], [4, 5, 6]], dtype=torch.float)  # torch.float默认为torch.float32
print(a.shape)  # torch.Size([2, 3])
print(a.size())  # torch.Size([2, 3])
print(a.dim())  # 2
print(a.dtype)  # torch.float32
print(a.type())  # torch.FloatTensor
print(type(a))  # <class 'torch.Tensor'>

b = cv2.imread(r'E:\000.jpg')
print(b.shape)  # (900, 1440, 3)
print(b.size)  # 3888000
print(b.ndim)  # 3
print(b.dtype)  # uint8
print(type(b))  # <class 'numpy.ndarray'>

Supongo que te gusta

Origin blog.csdn.net/weixin_48158964/article/details/132401657
Recomendado
Clasificación