Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Fix Model.load fail if model_params is str (#2805)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryant1410 authored and matt-gardner committed Jun 14, 2019
1 parent e7b0013 commit ac72c88
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions allennlp/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def load(cls,
"""

# Peak at the class of the model.
model_type = config["model"]["type"]
model_type = config["model"] if isinstance(config["model"], str) else config["model"]["type"]

# Load using an overridable _load method.
# This allows subclasses of Model to override _load.
Expand Down Expand Up @@ -354,9 +354,10 @@ def extend_embedder_vocab(self, embedding_sources_mapping: Dict[str, str] = None
model_path=model_path)

def remove_pretrained_embedding_params(params: Params):
keys = params.keys()
if 'pretrained_file' in keys:
del params['pretrained_file']
for value in params.values():
if isinstance(value, Params):
remove_pretrained_embedding_params(value)
if isinstance(params, Params): # The model could possible be a string, for example.
keys = params.keys()
if 'pretrained_file' in keys:
del params['pretrained_file']
for value in params.values():
if isinstance(value, Params):
remove_pretrained_embedding_params(value)

0 comments on commit ac72c88

Please sign in to comment.