首页 > 其他 > 详细

报错RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed

时间:2021-06-09 17:55:08      阅读:30      评论:0      收藏:0      [点我收藏+]

训练GAN net时经常遇到这个问题

RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed. Specify retain_graph=True when calling .backward() or autograd.grad() the first time.

翻译一下就是 第二次尝试在图中向后遍历时,保存的临时变量已经被释放

显然,

GAN中有一个变量存在于gen和disc之间,就是fake

加上detach() 就行

技术分享图片

 

报错RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed

原文:https://www.cnblogs.com/lfri/p/14866263.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!