You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.py 533B

12345678910111213141516171819202122232425
  1. import random
  2. from enum import Enum
  3. import numpy as np
  4. import torch
  5. def set_seed(seed: int = 42) -> None:
  6. """
  7. Set the random seed for reproducibility.
  8. Args:
  9. seed (int): The seed value to set for random number generation.
  10. """
  11. torch.manual_seed(seed)
  12. random.seed(seed)
  13. np.random.default_rng(seed)
  14. if torch.cuda.is_available():
  15. torch.cuda.manual_seed_all(seed)
  16. class Target(str, Enum): # ↔ PyKEEN's LABEL_* constants
  17. HEAD = "head"
  18. TAIL = "tail"
  19. RELATION = "relation"