RuntimeError: Trying to backward through the graph a second time (or directly access saved tensors a

文章讨论了在将neuron.IFnode层添加到传统ANN模型时遇到的RuntimeError,原因在于未在训练过程中正确保存中间值。解决方法是在训练时调用`functional.reset_net(model)`来避免这个问题。
摘要由CSDN通过智能技术生成

SNN相关问题

问题:在传统ANN模型中直接修改,加入neuron.IFnode层后报错,

RuntimeError: Trying to backward through the graph a second time (or directly access saved tensors after they have already been freed). Saved intermediate values of the graph are freed when you call .backward() or autograd.grad(). Specify retain_graph=True if you need to backward through the graph a second time or if you need to access saved tensors after calling backward.
 

解决:忘记在训练过程中添加

functional.reset_net(model)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值