disable_imperative

paddle.fluid.dygraph.disable_imperative()[源代码]

该接口退出动态图模式。

返回

代码示例

  1. import paddle.fluid as fluid
  2. fluid.dygraph.enable_imperative() # Now we are in imperative mode
  3. x = fluid.layers.ones( (2, 2), "float32")
  4. y = fluid.layers.zeros( (2, 2), "float32")
  5. z = x + y
  6. print( z.numpy() ) #[[1, 1], [1, 1]]
  7. fluid.dygraph.disable_imperative() # Now we are in declarative mode