Saves this model on disk. Arguments: output_dir: Output directory where the model is saved.
(self, output_dir: str)
| 362 | self._files[filename] = path |
| 363 | |
| 364 | def save(self, output_dir: str) -> None: |
| 365 | """Saves this model on disk. |
| 366 | |
| 367 | Arguments: |
| 368 | output_dir: Output directory where the model is saved. |
| 369 | """ |
| 370 | self._serialize(os.path.join(output_dir, "model.bin")) |
| 371 | if self._config is not None: |
| 372 | self._config.save_as_json(os.path.join(output_dir, "config.json")) |
| 373 | |
| 374 | for filename, path in self._files.items(): |
| 375 | destination = os.path.join(output_dir, filename) |
| 376 | if os.path.exists(destination): |
| 377 | raise RuntimeError( |
| 378 | "File %s already exists in the model directory" % destination |
| 379 | ) |
| 380 | shutil.copy(path, destination) |
| 381 | |
| 382 | def _serialize(self, path): |
| 383 | """Serializes the model variables.""" |