解决Pytorch RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
问题
使用IEG系列过程中,发生如下问题RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
:
原因
模型写错了!!要注意要用meta module!!不能常规的nn.Module
,因为这里面返回的params
都是nn.Paramter
而非像MetaModule
那样是torch.tensor
解决方法
直接改回来就好了!!
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.