Skip to content

Commit

Permalink
model saving through torch.save(), CUDA deterministic mode, correct p…
Browse files Browse the repository at this point in the history
…refix for eval callback
  • Loading branch information
migalkin committed Feb 20, 2022
1 parent 6929b57 commit e9dcb4e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
# fix the seed for reproducibility
set_random_seed(42)

# for GNN layer reproducibility
torch.use_deterministic_algorithms(True)

@click.command()
@click.option('-ds', '--dataset_size', type=str, default="small") # or large
@click.option('-dim', '--embedding_dim', type=int, default=100)
Expand Down Expand Up @@ -99,7 +102,7 @@ def main(
callback_kwargs=dict(
evaluator=valid_evaluator,
evaluation_triples=dataset.inductive_validation.mapped_triples,
prefix="training",
prefix="validation",
frequency=1,
additional_filter_triples=dataset.inductive_inference.mapped_triples,
batch_size=batch_size,
Expand Down Expand Up @@ -135,7 +138,7 @@ def main(

# saving the final model
if save_model:
model.save_state("./data/model.pth")
torch.save(model, "./data/model.pth")


if __name__ == "__main__":
Expand Down

0 comments on commit e9dcb4e

Please sign in to comment.