- 博客(4)
- 资源 (1)
- 收藏
- 关注
原创 contiguous()方法
Users\Administrator\AppData\Local\Temp\.py:1:UserWarning:TypedStorage已弃用。现在,如果需要访问不带类型的底层存储,可以使用 tensor.untyped_storage()。看来在某些更新版本的PyTorch中,确实引入了 untyped_storage() 方法,以替代原有的 .storage() 方法,要直接访问UntypedStorage,请使用tensor.untyped_storage()而不是tensor.storage()
2024-02-25 18:49:58
2179
原创 张量的内存存储方式,维度dim,形状shape,步长stride,偏移量storage_offse,storage函数
使用索引(i,j,k)访问三维的元素会等效于访问内存中的第storage_offset+stride(0)*i + stride(1)*j + stride(2)*k个元素。代入上面公式就可以得到3,也就s[0,1,1]通过索引[0,1,1]出来的是2,s.storage()[3]通过索引[3]索引出来也是2.即内存中的第4个数。总结:偏移量(storage()索引):storage_offset+stride(0)*i + stride(1)*j + stride(2)*k。列如s[1],也是连续的。
2024-02-25 17:40:54
961
原创 pytorch张量数据类型
16位浮点型:torch.float16或torch.half torch.HalfTensor torch.cuda.HalfTensor 8无符号整型:torch.uint8 torch.ByteTensor torch.cuda.ByteTensor。类型都被整合到了torch.Tensor 类型中。pytorch一共支持9中数据类型。
2024-02-21 16:34:10
802
张量的内存存储方式,维度dim,形状shape,步长stride,偏移量storage-offse,storage函数
2024-02-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅
2