当前位置:网站首页>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()
必须将参数更新放在最后
边栏推荐
- 首次在我们的centos登录我们的Mysql
- unity 报错 Unsafe code may only appear if compiling with /unsafe. Enable “Allow ‘unsafe‘ code“ in Pla
- 元素的盒子模型+标签的尺寸大小和偏移量+获取页面滚动距离
- ABAP 里文件操作涉及到中文字符集的问题和解决方案
- UI遍历的初步尝试
- ITK编译remote库
- 【UNR #6 B】机器人表演(DP)
- Solve the problem of sed replacement text containing special characters such as "/" and "#"
- Process management and task management
- 51单片机驱动HMI串口屏,串口屏的下载方式
猜你喜欢
随机推荐
【Grpc】简介
【LeetCode】求根节点到叶节点数字之和
Teach you how to write performance test cases
[LeetCode] Find the sum of the numbers from the root node to the leaf node
【web渗透】SSRF漏洞超详细讲解
web开发概述
3438. 数制转换
什么是持续测试?
分析 20 个 veToken 生态系统协议 这种代币模型为何受欢迎?
Unity vertex animation
GB28181 sip和RTSP(Real-Time Streaming Protocol)实时流控制协议
[论文阅读] Multimodal Unsupervised Image-to-Image Translation
【每日一题】1413. 逐步求和得到正数的最小值
Visual low-code system practice based on design draft identification
C# rounding MidpointRounding.AwayFromZero
华为HCIE云计算之FC添加ipsan数据存储
Unity开发者必备的编辑器技巧
跳房子游戏
高并发+海量数据下如何实现系统解耦?【下】
RESOURCE_EXHAUSTED: etcdserver: mvcc: database space exceeded








