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")


目录
相关文章
|
3月前
|
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
|
4月前
|
机器学习/深度学习 数据处理 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
58 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

热门文章

最新文章

  • 1
    Error: Package awesomeProject contains more than one main function Consider using File kind instead
    60
  • 2
    深度探索 Elasticsearch 8.X:function_score 参数解读与实战案例分析
    148
  • 3
    【C++入门到精通】function包装器 | bind() 函数 C++11 [ C++入门 ]
    84
  • 4
    DataWorks操作报错合集之DataWorksUDF 报错:evaluate for user defined function xxx cannot be loaded from any resources,该怎么处理
    101
  • 5
    DataWorks产品使用合集之在 DataWorks 中,Function Studio 功能如何解决
    75
  • 6
    DataWorks产品使用合集之在 DataWorks 中的 ODPS UDF(User-Defined Function,用户自定义函数)中,支持不定长参数如何解决
    70
  • 7
    Serverless 应用引擎操作报错合集之在阿里函数计算中,函数执行超时,报错Function time out after如何解决
    61
  • 8
    Serverless 应用引擎操作报错合集之在阿里函数计算中,云函数怎么一直报错Function instance exited unexpectedly(code 1, message:operation not permitted) with start command 'php server.php '.如何解决
    141
  • 9
    Serverless 应用引擎操作报错合集之阿里函数计算中我打开sd时遇到错误,信息为"Function instance exited unexpectedly(code 1, message:operation not permitted) with start command ' '."如何解决
    284
  • 10
    Serverless 应用引擎操作报错合集之阿里函数计算中配置完fc,出现‘Function instance exited unexpectedly(code 1, message:operation not permitted) with start command 'npm run start '. 报错如何解决
    196