MCPcopy Create free account
hub / github.com/baidu/lac / init_pretraining_params

Function init_pretraining_params

python/LAC/utils.py:155–173  ·  view source on GitHub ↗

load params of pretrained model, NOT including moment, learning_rate

(exe,
                            pretraining_params_path,
                            main_program)

Source from the content-addressed store, hash-verified

153
154
155def init_pretraining_params(exe,
156 pretraining_params_path,
157 main_program):
158 """load params of pretrained model, NOT including moment, learning_rate"""
159 assert os.path.exists(pretraining_params_path
160 ), "[%s] cann't be found." % pretraining_params_path
161
162 def _existed_params(var):
163 if not isinstance(var, fluid.framework.Parameter):
164 return False
165 return os.path.exists(os.path.join(pretraining_params_path, var.name))
166
167 fluid.io.load_vars(
168 exe,
169 pretraining_params_path,
170 main_program=main_program,
171 predicate=_existed_params)
172 print("Load pretraining parameters from {}.".format(
173 pretraining_params_path))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected