load_program_state

paddle.static. load_program_state ( model_path, var_list=None ) [source]

Load program state from local file

Parameters
  • model_path (str) – The file prefix store the program

  • var_list (list|tuple, optional) – The Tensor list/tuple to load saved with [ save_params, save_persistables, save_vars ]. Default: None. The var_list is only used to get name, will not be modified.

Returns

the dict store Parameter and optimizer information

Return type

state_dict(dict)

Examples

import paddle
import paddle.static as static

paddle.enable_static()

x = static.data(name="x", shape=[10, 10], dtype='float32')
y = static.nn.fc(x, 10)
z = static.nn.fc(y, 10)

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

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