Skip to content

Commit 401da56

Browse files
fix(model): when trasnferring weights from another model, copy the config file too
1 parent 8f23c13 commit 401da56

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libraries/mathy_python/mathy/agents/policy_value_model.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,18 @@ def get_or_create_policy_model(
189189
init_model_path = os.path.join(args.init_model_from, args.model_name)
190190
opt = f"{init_model_path}.optimizer"
191191
mod = f"{init_model_path}.h5"
192-
if os.path.exists(f"{model_path}.h5"):
192+
cfg = f"{init_model_path}.config.json"
193+
if os.path.exists(f"{model_path}.bytes"):
193194
print_error(
194195
ValueError("Model Exists"),
195196
f"Cannot initialize on top of model: {model_path}",
196197
print_error=False,
197198
)
198-
if os.path.exists(opt) and os.path.exists(mod):
199+
if os.path.exists(opt) and os.path.exists(mod) and os.path.exists(cfg):
199200
print(f"initialize model from: {init_model_path}")
200201
copyfile(opt, f"{model_path}.optimizer")
201202
copyfile(mod, f"{model_path}.h5")
203+
copyfile(cfg, f"{model_path}.config.json")
202204
else:
203205
print_error(
204206
ValueError("Model Exists"),

0 commit comments

Comments
 (0)