首先查看变量x类型是numpy ndarray还是pytorch tensor
print(type(x))
然后根据x类型
numpy ndarray: x.nbytes(字节)
pytorch tensor: x.element_size()*x.nelement()(字节)
首先查看变量x类型是numpy ndarray还是pytorch tensor
print(type(x))
然后根据x类型
numpy ndarray: x.nbytes(字节)
pytorch tensor: x.element_size()*x.nelement()(字节)