当前位置:网站首页>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()
必须将参数更新放在最后
边栏推荐
- 分析 20 个 veToken 生态系统协议 这种代币模型为何受欢迎?
- Web性能测试模型小结
- 首次在我们的centos登录我们的Mysql
- 浏览器中的history详解
- Unity开发者必备的编辑器技巧
- hint: Updates were rejected because the tip of your current branch is behind hint: its remote counte
- 力扣每日一题-第51天-744. 寻找比目标字母大的最小字母
- Chip Information|Semiconductor revenue growth expected to slow to 7%, Bluetooth chip demand still growing steadily
- HCIP——综合交换实验
- 【每日一题】1413. 逐步求和得到正数的最小值
猜你喜欢
基于设计稿识别的可视化低代码系统实践
Aptos 深度解读:机遇、挑战与风险
RESOURCE_EXHAUSTED: etcdserver: mvcc: database space exceeded
C# 四舍五入 MidpointRounding.AwayFromZero
Process management and task management
Linux(Centos7)服务器中配置Mysql主从数据库,以及数据库的安装,防火墙操作
Web性能测试模型小结
Button countdown reminder
Visual low-code system practice based on design draft identification
具有多孔光纤的偏振分束器
随机推荐
【论文笔记】基于深度学习的机器人抓取虚拟仿真实验教学系统
这一次,话筒给你:向自由软件之父 Richard M. Stallman 提问啦!
Chip Information|Semiconductor revenue growth expected to slow to 7%, Bluetooth chip demand still growing steadily
Entity FrameWork Core教程,从基础应用到原理实战
跳房子游戏
odoo公用变量或数组的使用
JCMsuite—单模光纤传播模式
中文NER的SOTA:RICON
【内存管理概述 Objective-C语言】
实操|风控模型中常用的这三种预测方法与多分类场景的实现
【机器学习】随机森林、AdaBoost、GBDT、XGBoost从零开始理解
【Grpc】报错:status = StatusCode.UNIMPLEMENTED details = ““
【每日一题】1413. 逐步求和得到正数的最小值
RedHat红帽RHEL7安装与使用,VMware Workstation16 Pro虚拟机的安装与使用
20220809-PotPlayer如何设置默认字体色-设置默认字体色的方法
Experimental support for decorators may change in future releases.Set the "experimentalDecorators" option in "tsconfig" or "jsconfig" to remove this warning
UI遍历的初步尝试
解决sed替换文本,里面含有“/“、“#”等特殊字符的问题
防勒索病毒现状分析
彩色袜子题