代码debug:RuntimeError: You must implement the backward function for custom autograd.Function.

Posted 呆呆象呆呆

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了代码debug:RuntimeError: You must implement the backward function for custom autograd.Function.相关的知识,希望对你有一定的参考价值。

RuntimeError: You must implement the backward function for custom autograd.Function.

问题原因

image-20210722092751648

问题解决

主要原因是自己写的loss梯度 回传函数有问题

参考一下这一篇blog学习了一下怎么写自己的loss和网络梯度回传

一开始的错误代码是这样的

image-20210722093255557

没有加上@staticmethod

加上后就可以用了

以上是关于代码debug:RuntimeError: You must implement the backward function for custom autograd.Function.的主要内容,如果未能解决你的问题,请参考以下文章

MNIST读取出错RuntimeError Dataset not found.You can download解决方案

Keras 编码器-解码器模型 RuntimeError: You must compile your model before using it

RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.

RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.

RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.

The version of SOS does not match the version of CLR you are debugging