enabled

paddle.fluid.dygraph.base. enabled ( ) [source]

This function checks whether the program runs in dynamic graph mode or not. You can enter dynamic graph mode with api_fluid_dygraph_guard api, or enable and disable dynamic graph mode with api_fluid_dygraph_enable_dygraph and api_fluid_dygraph_disable_dygraph api .

Note:

fluid.dygraph.enabled is the alias of fluid.in_dygraph_mode, and fluid.in_dygraph_mode is recommended to use.

Returns

Whether the program is running in dynamic graph mode.

Return type

bool

Examples

import paddle.fluid as fluid

fluid.enable_dygraph()  # Now we are in dygragh mode
print(fluid.dygraph.enabled())  # True
fluid.disable_dygraph()
print(fluid.dygraph.enabled())  # False