Skip to content

Commit

Permalink
Merge pull request #7 from microsoft/mallamanis/simplify-saving
Browse files Browse the repository at this point in the history
Simplify model saving, when parent folder doesn't exist.
  • Loading branch information
Miltos authored Nov 27, 2020
2 parents 0ba8308 + cceac45 commit 2ef1159
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ptgnn/baseneuralmodel/abstractneuralmodel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing_extensions import final

import gzip
import os
import torch
from abc import ABC, abstractmethod
from concurrent import futures
Expand Down Expand Up @@ -151,6 +152,7 @@ def build_neural_module(self) -> TNeuralModule:

# region Saving/Loading
def save(self, path: Path, model: TNeuralModule) -> None:
os.makedirs(os.path.dirname(str(path)), exist_ok=True)
with gzip.open(path, "wb") as f:
torch.save((self, model), f)

Expand Down

0 comments on commit 2ef1159

Please sign in to comment.