(epoch, is_temp=False, is_last=False)
| 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? |
no test coverage detected
searching dependent graphs…