首页 > 解决方案 > 如何使用静态转发方法制作新型 autograd 函数。?

问题描述

错误是:

Traceback (most recent call last):

  File "<ipython-input-5-401374f4bdee>", line 39, in <module>
    frame  = detect(frame, net.eval(), transform)

  File "<ipython-input-5-401374f4bdee>", line 14, in detect
    y = net(x)

  File "C:\Users\kusha\anaconda3\envs\virtual_platform\lib\site-packages\torch\nn\modules\module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)

  File "C:\Users\kusha\OneDrive\Desktop\Computer_Vision_A_Z_Template_Folder\Module 2 - Object Detection\ssd.py", line 101, in forward
    self.priors.type(type(x.data))                  # default boxes

  File "C:\Users\kusha\anaconda3\envs\virtual_platform\lib\site-packages\torch\autograd\function.py", line 145, in __call__
    "Legacy autograd function with non-static forward method is deprecated. "

RuntimeError: Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)

我已经尝试了错误中说明的 autograd 函数的 PyTorch 文档作为示例链接,但它没有锻炼

标签: pythoncomputer-visiontorchautograd

解决方案


推荐阅读