目的:

固定住训练的顺序等变量,使实验可复现

def setup_seed(seed):
    torch.manual_seed(seed)
    torch.cuda.manual_seed_all(seed)
    np.random.seed(seed)
    random.seed(seed)
    torch.backends.cudnn.deterministic = True

setup_seed(1)

Ref:

http://www.ishenping.com/ArtInfo/3265474.html
https://www.lizenghai.com/archives/30179.html

相关文章:

  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2021-12-04
  • 2021-06-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-09-13
  • 2021-11-30
  • 2022-12-23
  • 2021-06-26
相关资源
相似解决方案