Fixes "Error saving model" #1622

This commit is contained in:
Isaac Sijaranamual 2017-12-10 21:29:50 +01:00
parent 568130ce7c
commit 20ae0c459a

View File

@ -3,7 +3,6 @@ from __future__ import unicode_literals, division, print_function
import plac import plac
from pathlib import Path from pathlib import Path
import dill
import tqdm import tqdm
from thinc.neural._classes.model import Model from thinc.neural._classes.model import Model
from timeit import default_timer as timer from timeit import default_timer as timer
@ -165,9 +164,9 @@ def train(cmd, lang, output_dir, train_data, dev_data, n_iter=30, n_sents=0,
gpu_wps=gpu_wps) gpu_wps=gpu_wps)
finally: finally:
print("Saving model...") print("Saving model...")
with (output_path / 'model-final.pickle').open('wb') as file_: with nlp.use_params(optimizer.averages):
with nlp.use_params(optimizer.averages): final_model_path = output_path / 'model-final'
dill.dump(nlp, file_, -1) nlp.to_disk(final_model_path)
def _render_parses(i, to_render): def _render_parses(i, to_render):