in_dygraph_mode

paddle.fluid.in_dygraph_mode()[source]

This function checks whether the program runs in dynamic graph mode or not. You can enter dynamic graph mode with guard api, or enable and disable dynamic graph mode with api_fluid_dygraph_enable and api_fluid_dygraph_disable api .

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.in_dygraph_mode())  # True
fluid.disable_dygraph()
print(fluid.in_dygraph_mode())  # False