set_program_state

paddle.fluid.io.set_program_state(program, state_dict)[source]

Set program parameter from state_dict

An exception will throw if shape or dtype of the parameters is not match.

NOTICE: This function MUST called after run start_up_program

Parameters
  • program (Program) – The program to be set

  • state_dict (dict) – the dict store Parameter and optimizer information

Returns

None

Examples

import paddle.fluid as fluid
x = fluid.data( name="x", shape=[10, 10], dtype='float32')
y = fluid.layers.fc( x, 10)
z = fluid.layers.fc( y, 10)

place = fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run( fluid.default_startup_program() )
prog = fluid.default_main_program()

fluid.save( prog, "./temp")
program_state = fluid.load_program_state( "./temp")

fluid.set_program_state( prog, program_state)