Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3.

简介: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3.

PyTorch在1.3版本及之后,规定forward方法必须是静态方法。违反了该原则的代码将会在运行时报下列错误:


..\torch\csrc\autograd\python_function.cpp:622: UserWarning: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)

解决办法:



将PyTorch降级到1.2版本及以下,因为这个改进直到1.3版本才正式生效;


手动忽略掉UserWarning:


      import warnings


      warnings.filterwarnings("ignore")


目录
相关文章
|
4月前
|
Python
【Azure 应用服务】Azure Function HTTP Trigger 遇见奇妙的500 Internal Server Error: Failed to forward request to http://169.254.130.x
【Azure 应用服务】Azure Function HTTP Trigger 遇见奇妙的500 Internal Server Error: Failed to forward request to http://169.254.130.x
|
5月前
|
机器学习/深度学习 数据处理 Python
【Python】已解决:FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated
【Python】已解决:FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated
102 0
【问题记录】utureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0
【问题记录】utureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0

热门文章

最新文章