Skip to content

Commit

Permalink
Improved backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
swansonk14 committed Dec 6, 2020
1 parent 5371b29 commit 206950c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions chemprop/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import math
import os
import pickle
import re
from time import time
from typing import Any, Callable, List, Tuple, Union

Expand Down Expand Up @@ -103,10 +104,9 @@ def load_checkpoint(path: str,
# Skip missing parameters and parameters of mismatched size
pretrained_state_dict = {}
for loaded_param_name in loaded_state_dict.keys():

# Backward compatibility for parameter names
if loaded_param_name.startswith('encoder.encoder.W'):
param_name = loaded_param_name.replace('encoder.encoder.W', 'encoder.encoder.0.W')
if re.match(r'(encoder\.encoder\.)([Wc])', loaded_param_name):
param_name = loaded_param_name.replace('encoder.encoder', 'encoder.encoder.0')
else:
param_name = loaded_param_name

Expand Down

0 comments on commit 206950c

Please sign in to comment.