如何让每次实验运行后得到的结果都一致?
可以通过将以下设置放在 import 后,正式代码前:

np.random.seed(0)
random.seed(0)
torch.manual_seed(0)
torch.cuda.manual_seed(0)
torch.backends.cudnn