赞
踩
在PyTorch中,张量(Tensor)的三大属性是 torch.dtype
、torch.device
和 torch.layout
。
torch.dtype
(数据类型)torch.dtype
表示张量中元素的数据类型。PyTorch 支持多种数据类型,每种数据类型都表示特定的数值范围和精度。常用的数据类型包括:
torch.float32
或 torch.float
: 单精度浮点数,常用的默认类型torch.float64
或 torch.double
: 双精度浮点数torch.float16
或 torch.half
: 半精度浮点数,适用于内存和计算量有限的场景torch.int8
: 8位整数torch.uint8
: 8位无符号整数torch.int16
或 torch.short
: 16位整数torch.int32
或 torch.int
: 32位整数torch.int64
或 torch.long
: 64位整数示例:
import torch
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。