Hello everybody!
I did as above and had the problem
Code:
def seed_torch(seed=0):
random.seed(seed)#
os.environ[‘PYTHONHASHSEED’] = str(seed)#
np.random.seed(seed)#
torch.manual_seed(seed)#
torch.cuda.manual_seed(seed)#
torch.cuda.manual_seed_all(seed)# # if you are using multi-GPU.
torch.backends.cudnn.benchmark = False#
torch.backends.cudnn.deterministic = True#
seed_torch()
net_basnet.train()
for i, data in enumerate(train_dataloader):
seed_torch()
…
…
seed_torch()
net_basnet.eval()
seed_torch()
with torch.no_grad():
for i, data in enumerate(val_dataloader):
seed_torch()
…
I have the same results of training loss. However, I have different results of validation loss, even putting seed_torch() everywhere in loops. Please help me solve this problem!!!. Thank you!