MCPcopy
hub / github.com/explosion/spaCy / _save_model

Function _save_model

spacy/training/pretrain.py:70–86  ·  view source on GitHub ↗
(epoch, is_temp=False, is_last=False)

Source from the content-addressed store, hash-verified

68 msg.row(("#", "# Words", "Total Loss", "Loss", "w/s"), **row_settings)
69
70 def _save_model(epoch, is_temp=False, is_last=False):
71 is_temp_str = ".temp" if is_temp else ""
72 with model.use_params(optimizer.averages):
73 if is_last:
74 save_path = output_dir / f"model-last.bin"
75 else:
76 save_path = output_dir / f"model{epoch}{is_temp_str}.bin"
77 with (save_path).open("wb") as file_:
78 file_.write(model.get_ref("tok2vec").to_bytes())
79 log = {
80 "nr_word": tracker.nr_word,
81 "loss": tracker.loss,
82 "epoch_loss": tracker.epoch_loss,
83 "epoch": epoch,
84 }
85 with (output_dir / "log.jsonl").open("a") as file_:
86 file_.write(srsly.json_dumps(log) + "\n")
87
88 # TODO: I think we probably want this to look more like the
89 # 'create_train_batches' function?

Callers 1

pretrainFunction · 0.85

Calls 2

use_paramsMethod · 0.80
to_bytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…