当前位置:网站首页>one of the variables needed for gradient computation has been modified by an inplace
one of the variables needed for gradient computation has been modified by an inplace
2022-08-10 01:18:00 【江_小_白】
项目场景:
根据项目要求,需要使用两个优化器对模型进行优化
问题描述
运行中一直出现:
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [100, 5000]], which is output 0 of TBackward, is at version 3; expected version 2 instead. Hint: enable anomaly detection
解决方案:
经过网上查询发现,这个问题可能是由于出现了x+=3类似的代码,改成x = x + 1,更改过后发现仍旧不行,后来发现,在使用两个优化器进行优化是需要是如下格式:
optimizerG.zero_grad()
optimizerD.zero_grad()
loss1.backward(retain_graph=True)
loss2.backward()
optimizerD.step()
optimizerG.step()
必须将参数更新放在最后
边栏推荐
猜你喜欢
卷积神经网络识别验证码
高压之下,必有懦夫
[论文阅读] Multimodal Unsupervised Image-to-Image Translation
翻译工具-翻译工具下载批量自动一键翻译免费
【kali-密码攻击】(5.1.2)密码在线破解:Medusa
In the 2022 gold, nine, silver and ten work tide, how can I successfully change jobs and get a high salary?
【干货】集成学习原理总结
Problems and solutions related to Chinese character set in file operations in ABAP
按钮倒计时提醒
20220809-PotPlayer如何设置默认字体色-设置默认字体色的方法
随机推荐
芯片资讯|半导体收入增长预计将放缓至 7%,蓝牙芯片需求依然稳步增长
Interdepartmental Communication Skills
HCIP——综合交换实验
Unity editor extension interface uses List
【无标题】
Initial attempt at UI traversal
Sikuli 基于图形识别的自动化测试技术
STM32F103驱动HCSR04超声波测距显示
Sikuli's Automated Testing Technology Based on Pattern Recognition
夏克-哈特曼波前传感器
In the 2022 gold, nine, silver and ten work tide, how can I successfully change jobs and get a high salary?
web开发概述
Initial attempt at UI traversal
Unity碰撞和触发
实操|风控模型中常用的这三种预测方法与多分类场景的实现
组件的使用
惊掉你下巴,程序员编码竟然可以被 996 指数化
小程序开发的报价为什么有差别?需要多少钱?
grafana9配置邮箱告警
用于X射线光学器件的哈特曼波前传感器