当前位置:网站首页>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()
必须将参数更新放在最后
边栏推荐
- Linux(Centos7)服务器中配置Mysql主从数据库,以及数据库的安装,防火墙操作
- 人际关系不仅要“存”,更要“激活”!
- 力扣每日一题-第51天-744. 寻找比目标字母大的最小字母
- C# rounding MidpointRounding.AwayFromZero
- .Net interview experience summary
- Teach you how to write performance test cases
- 基于设计稿识别的可视化低代码系统实践
- 你有对象类,我有结构体,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang结构体(struct)的使用EP06
- DHCP——动态主机配置协议
- ITK编译remote库
猜你喜欢

牛客刷题——剑指offer(第四期)

y92.第六章 微服务、服务网格及Envoy实战 -- Envoy基础(三)

unity 报错 Unsafe code may only appear if compiling with /unsafe. Enable “Allow ‘unsafe‘ code“ in Pla

夏克-哈特曼波前传感器

首次在我们的centos登录我们的Mysql

Unity image is blurry after using long image

type-C 边充电边听歌(OTG) PD芯片方案,LDR6028 PD充电加OTG方案
![[LeetCode] Find the sum of the numbers from the root node to the leaf node](/img/1c/6c627e17a60f424601226504f4ff36.png)
[LeetCode] Find the sum of the numbers from the root node to the leaf node

RESOURCE_EXHAUSTED: etcdserver: mvcc: database space exceeded

基于FTP协议实现文件上传与下载
随机推荐
[Syntax sugar] About the mapping of category strings to category numeric ids
实操|风控模型中常用的这三种预测方法与多分类场景的实现
Sikuli's Automated Testing Technology Based on Pattern Recognition
[QNX Hypervisor 2.2用户手册]10.14 smmu
多线程之自定义线程池
The shell specifies the parameter name to pass the parameter
[Swoole Series 3.5] Process Pool and Process Manager
Entity FrameWork Core教程,从基础应用到原理实战
Aptos 深度解读:机遇、挑战与风险
中文NER的SOTA:RICON
Solidity最强对手:MOVE语言及新公链崛起
力扣每日一题-第51天-744. 寻找比目标字母大的最小字母
手把手教你编写性能测试用例
Process management and task management
你有对象类,我有结构体,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang结构体(struct)的使用EP06
微信小程序tab切换时保存checkbox状态
JCMsuite—单模光纤传播模式
grafana9配置邮箱告警
【UNR #6 C】稳健型选手(分治)(主席树)(二分)
组件的使用