pytorch随机数种子设置

if args.seed is not None:
       torch.manual_seed(args.random_seed)
       torch.cuda.manual_seed(args.random_seed)
       torch.cuda.manual_seed_all(args.random_seed)
       np.random.seed(args.random_seed)
       random.seed(args.random_seed)
       torch.backends.cudnn.benchmark = False
       torch.backends.cudnn.deterministic = True

你可能感兴趣的:(python随笔,python,tensorflow,gpu)