dynamic-soft-margin-pytorch icon indicating copy to clipboard operation
dynamic-soft-margin-pytorch copied to clipboard

Running the script multiple times, the results are different.

Open lovekittynine opened this issue 5 years ago • 5 comments

Hello, thank you! I get some questions when i run your script. detailed: Running the script multiple times, the results are different.

Looking forward to your reply! Thank you!

lovekittynine avatar Dec 19 '19 12:12 lovekittynine

Do you mean training or inference? Inference results should not change unless your update PyTorch or cudnn. Training results are not guaranteed to be consistent (because it's SGD) but they should be close enough.

lg-zhang avatar Dec 20 '19 17:12 lg-zhang

thanks for your reply!In training stage, even though i set random seed,the results are different each time!Other works,such as Hardnet,it can get same training results,when set identical random seed.

lovekittynine avatar Dec 21 '19 05:12 lovekittynine

Could you specify what random seeds have you set? To make training deterministic, normally you need to fix seeds for pytorch, random, np.random and also set cudnn to deterministic mode.

lg-zhang avatar Dec 23 '19 18:12 lg-zhang

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

lovekittynine avatar Dec 24 '19 05:12 lovekittynine

Could you try: random.seed(0)?

lg-zhang avatar Dec 24 '19 05:12 lg-zhang