disable_imperative

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

该接口退出动态图模式。

返回

代码示例

  1. import paddle.fluid as fluid
  2. fluid.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.disable_imperative() # Now we are in declarative mode