当前位置:网站首页>【PYTORCH】RuntimeError: one of the variables needed for gradient computation has been
【PYTORCH】RuntimeError: one of the variables needed for gradient computation has been
2022-06-13 07:44:00 【neu_ eddata_ yjzhang】
The environment of this experiment is pytorch=1.4.0. The reason for this mistake is pytorch Automatic derivation mechanism , In seeking loss When , Because of my loss It has been written.
loss = loss_0 + loss_1
This may be right pytorch The automatic derivation mechanism of has caused confusion , So I changed the above sentence into the following code , The program can be executed normally , But whether the specific effect is the same as the above , Not sure yet .
loss = loss_0.backward() + loss_1.backward()
Another way is that I put the original loss.backward() This line of code is changed to
loss1 = loss.detach_().requires_grad_(True)
loss1.backward()
The mistake is solved
边栏推荐
- C语言:如何给全局变量起一个别名?
- 2022年危险化学品经营单位安全管理人员特种作业证考试题库及模拟考试
- One article of quantitative framework backtrader read analyzer
- 2021-10-20
- Redis underlying data structure - underlying principle of hash table
- Login registration
- Coalesce() function
- redis-5. Redis' RDB, fork, copyonwrite, AOF, RDB & AOF are mixed
- Find the first and last positions of elements in a sorted array
- 25 domestic and foreign literature databases
猜你喜欢
Logback log framework learning and problems
Considerations for using redis transactions
C language: how to give an alias to a global variable?
Compare advantages and disadvantages of DFS and BFS and name vocabulary
Index push down (ICP) for mysql5.6
Oracle problem: the data in the field is separated by commas. Take the data on both sides of the comma
20 | pipeline oriented instruction design (Part 1): Modern CPU with multi-purpose
How app inventor accesses resource files in assets directory
Some optimization for seckill project
A troubleshooting process for database timeout caused by SQL misguided
随机推荐
Some optimization for seckill project
Leetcode 163 Missing interval (June 12, 2022)
Three handshakes and four waves of TCP protocol and why------ One two pandas
[MySQL] rapid data deletion recovery tool - binlog2sql
20 | 面向流水线的指令设计(上):一心多用的现代CPU
China phosphate market in-depth analysis and investment prospect forecast report 2022-2028
Coalesce() function
Oracle problem: the data in the field is separated by commas. Take the data on both sides of the comma
[introduction to flirting with girls on Valentine's day -- 63 lines of code to win]
20 | pipeline oriented instruction design (Part 1): Modern CPU with multi-purpose
[splashsplash] repeat the script that outputs splashsurf
MySQL table cache most detailed notes
6. system call
EF CORE执行SQL语句
QT reading SQLSERVER database
MySQL table partitioning
Data desensitization tool advance tool Datamask
[MySQL] online lock free delay free DDL artifact GH OST
Go 接口实现原理【高阶篇】: type _interface struct
23 | 冒险和预测(二):流水线里的接力赛