当前位置:网站首页>【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
边栏推荐
- Selenium reports an error deprecationwarning: executable_ path has been deprecated, please pass in a Service object
- 2021-10-20
- 论文笔记: 多标签学习 BP-MLL
- Login registration
- 23 | 冒险和预测(二):流水线里的接力赛
- Consistency under distributed
- A troubleshooting process for database timeout caused by SQL misguided
- 平衡二叉树学习笔记------一二熊猫
- DATE_ SUB()
- AQS - detailed explanation of reentrantlock source code
猜你喜欢
19 | establish data path (bottom): instruction + operation =cpu
Redis cluster parsing docker building redis cluster
Learning notes of balanced binary tree -- one two pandas
Paper notes: multi label learning bp-mll
Socket programming 2:io reuse (select & poll & epoll)
Tidb source code series: immersive compilation of tidb
Clickhouse column basic data type description
Considerations for using redis transactions
Hashtable source code analysis
A troubleshooting process for database timeout caused by SQL misguided
随机推荐
分布式系统之道:Lamport 逻辑时钟
leetcode 咒语和药水的成功对数
Redis master-slave replication - the underlying principle of partial resynchronization
[an example of MySQL startup error] innodb: failed to create check sector file, errno:13
Redis learning journey master-slave replication
Redis learning journey --redis Conf details
6. system call
redis-5. Redis' RDB, fork, copyonwrite, AOF, RDB & AOF are mixed
Redis learning journey -- do you know the data types of redis?
C#合并多个richtextbox内容时始终存在换行符的解决方法
25个国内外文献数据库
[MySQL change master error] slave is not configured or failed to initialize properly
[log4j2 log framework] modify dump log file permissions
19 | establish data path (bottom): instruction + operation =cpu
Login registration
Redis underlying data structure - underlying principle of hash table
How idea breaks point debugging
25 | adventure and prediction (IV): it's raining today. Will it rain tomorrow?
SFTP login and download file script
OpenHarmony笔记-----------(一)