PyTorch torch.get_default_dtype 函数
torch.get_default_dtype 是 PyTorch 中用于获取当前默认浮点数据类型的函数。
函数定义
torch.get_default_dtype()
使用示例
实例
import torch
# 获取默认 dtype
dtype = torch.get_default_dtype()
print("默认 dtype:", dtype)
# 获取默认 dtype
dtype = torch.get_default_dtype()
print("默认 dtype:", dtype)
输出结果为:
默认 dtype: torch.float32

Pytorch torch 参考手册