When i infer the same input, the output is not deterministic sometimes, and the code is as below.
Debug found that the posterior is same, but the sample is different for same input sometimes.
posterior = F.softmax(logits, dim=1) distrib = torch.distributions.Categorical(posterior) sample = distrib.sample().float()
I execute model.eval() and have set the seed at the begining. Do you have any suggestions? Thank you.
seed = 1234 torch.manual_seed(seed) torch.cuda.manual_seed(seed) torch.cuda.manual_seed_all(seed) np.random.seed(seed) random.seed(seed) torch.backends.cudnn.benchmark = False torch.backends.cudnn.deterministic = True