PyTorch torch.get_default_dtype 函数

约 251 字 更新于 2026-11-18 5iyo.com

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: torch.float32