enable_static

paddle. enable_static ( ) [源代码]

注解

从 2.0.0 版本开始,Paddle 默认开启动态图模式。

开启静态图模式。可通过 disable_static 关闭静态图模式。

返回

代码示例

import paddle
print(paddle.in_dynamic_mode())  # True, dynamic mode is turn ON by default since paddle 2.0.0

paddle.enable_static()
print(paddle.in_dynamic_mode())  # False, Now we are in static graph mode

paddle.disable_static()
print(paddle.in_dynamic_mode())  # True, Now we are in dynamic mode