dragen1860 / MAML-Pytorch

Elegant PyTorch implementation of paper Model-Agnostic Meta-Learning (MAML)
MIT License
2.31k stars 420 forks source link

Result is not deterministic because of iterating over Python dictionary #35

Open ShawnLixx opened 5 years ago

ShawnLixx commented 5 years ago

https://github.com/dragen1860/MAML-Pytorch/blob/98a00d41724c133bd29619a2fb2cc46dd128a368/MiniImagenet.py#L81 should be changed to OrderedDict.

Result can't be reproduced because the use of dictionary. Iterating over dict causes randomness. https://github.com/dragen1860/MAML-Pytorch/blob/98a00d41724c133bd29619a2fb2cc46dd128a368/MiniImagenet.py#L68

ShawnLixx commented 5 years ago

Also, random.seed should be called in the main function of training scripts.

semin-park commented 4 years ago

This is only a problem if you're using Python < 3.6 3.6 onwards, insertion order is maintained for the default dictionary as well.

https://stackoverflow.com/questions/1867861/how-to-keep-keys-values-in-same-order-as-declared

But still I do agree that it's more backward compatible to change it to OrderedDict as @ShawnLixx suggests

atseng17 commented 3 years ago

Even OrderedDict and random.seed are used, the results are still not reproducible.