当前位置:网站首页>[solution] paddlepaddle 2 X call static graph mode

[solution] paddlepaddle 2 X call static graph mode

2022-07-04 21:00:00 Allenpandas

Problem analysis

In PaddlePaddle 2.x, we turn on dynamic graph mode by default, and '%s()' is only supported in static graph mode. So if you want to use this api, please call 'paddle.enable_static()' before this api to enter static graph mode." % func.__name__
AssertionError: 
In PaddlePaddle 2.x, we turn on dynamic graph mode by default, and 'data()' is only supported in static graph mode. So if you want to use this api, please call 'paddle.enable_static()' before this api to enter static graph mode.

The problem is PaddlePaddle Bag 2.X In the version , The default is to start dynamic graph mode . however data() and %s Can only be supported in static graph mode , If you want to call this api Words , Must be called on api Before adding paddle.enable_static() This line of code .

Solution

#  Import paddlepaddle package 
import paddle
#  Then start the static diagram mode 
paddle.enable_static()
原网站

版权声明
本文为[Allenpandas]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207041928245981.html