torch.manual_seed()

torch.manual_seed(args.seed) #爲CPU設置種子用於生成隨機數,以使得結果是肯定的 if args.cuda: torch.cuda.manual_seed(args.seed)#爲當前GPU設置隨機種子;若是使用多個GPU,應該使用torch.cuda.manual_seed_all()爲全部的GPU設置種子。web
本站公眾號
   歡迎關注本站公眾號,獲取更多信息