TUTORIALAI 与数据科学FETCHED

PyTorch torch.get_default_dtype 函数

PyTorch torch.get_default_dtype 函数 Pytorch torch 参考手册 torch.get_default_dtype 是 PyTorch 中用于获取当前默认浮点数据类型的函数。 函数定义 torch.get_default_dtype() 使用示例 实例 [mycode4 type='python'] import torch # 获取默认 dtype dt..

更新于 2026/7/16

教程详情页默认 noindex。

PyTorch torch.get_default_dtype 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

torch.get_default_dtype 是 PyTorch 中用于获取当前默认浮点数据类型的函数。

函数定义

torch.get_default_dtype()

使用示例

实例

import torch

# 获取默认 dtype
dtype = torch.get_default_dtype()
print("默认 dtype:", dtype)

输出结果为:

默认 dtype: torch.float32

Pytorch torch 参考手册 Pytorch torch 参考手册