PyTorch 4-深度学习-torch
一: Tensors
tensor分为头信息区(Tensor)和存储区(Storage)
信息区主要保存着tensor的形状(size)、步长(stride)、数据类型(type)等信息,而真正的数据则保存成连续数组,存储在存储区;因为数据动辄成千上万,因此信息区元素占用内存较少,主要内存占用取决于tensor中元素的数目,即存储区的大小
1> tensor utilities
utilities | detail | demo |
---|---|---|
torch.is_tensor(obj) | tensor 数据返回True | x = torch.tensor([1, 1, 0]) print(torch.is_tensor(x)) ==>True |
torch.is_storage(obj) | tensor 存储对象 数据返回True | x = torch.FloatStorage(6) print(torch.is_storage(x)) ==>True |
torch.is_complex(input) | t |