pytorch - 为什么使用 torch.cuda.amp.GradScaler 时比例变为零?
问题描述
在使用 Pytorch 的自动混合精度包 ( amp )时,我使用以下代码片段来显示比例:
scaler = torch.cuda.amp.GradScaler(init_scale = 65536.0,growth_interval=1)
print(scaler.get_scale())
这是我得到的输出:
...
65536.0
32768.0
16384.0
8192.0
4096.0
...
1e-xxx
...
0
0
0
而这一步之后的所有损失都变成Nan
了(同时规模仍然为0)。
我的损失函数或训练数据有什么问题?
解决方案
推荐阅读
- authentication - 如何为我的 Sonos 应用程序添加身份验证模块
- mongodb - 使用 pymongo 在 Mongodb 中查找空记录
- android - 如何为安卓创建 IPSec/L2TP psk vpn
- angular - 如何使用Angular 5在表格中的特定行上显示按钮?
- asp.net - 如何在 PostgreSQL 中返回两个表
- dax - 计算一个表中列的不同值过滤表格模型DAX中的其他表
- python - 如何从python中记录的跳过
- android - 构建/生成文件夹中的清单类消失
- c - 如何释放指向整数数组的指针
- javafx - 将 HBox 设置为 TitledPane 的标题