list
>>>l = [1, 2, 3, 4]
>>>length = len(l)
4
np.array
shape
查看的是维度,.size
查看的是成员总数量,注意shape和size方法后面不要加括号
>>>import numpy as np
>>>a = np.array([[1, 2, 3],[1, 2, 3]])
>>>print(a.shape, a.size)
(2, 3) 6
Tensor
.shape
和.size()
方法都是查询维度,且.size()
要加括号
>>>a = torch.randn(2,2)
>>>a.shape
torch.Size([2,2])
>>>a.size()
torch.Size([2,2])