mardi 15 novembre 2016

random permutation in python2 and torch7

I've been working with caffe and torch, trying to replicate some experiments when I came across something interesting. It seems the the python numpy.random.permuation and torch.randperm result in different values when the same seed is used.

python2

>>> import numpy
>>> numpy.random.seed(3)
>>> numpy.random.uniform()
0.5507979025745755
>>> numpy.random.seed(3)
>>> numpy.random.permutation(10)
array([5, 4, 1, 2, 9, 6, 7, 0, 3, 8])
>>>

torch7

th> torch.manualSeed(3)                                      [0.0001s]
th> torch.uniform()
0.55079790437594                                             [0.0002s]
th> torch.manualSeed(3)                                      [0.0001s]
th> torch.randperm(10)
7
1
4
8
9
6
2
10
3
5
[torch.DoubleTensor of size 10]                              [0.0005s]
th> 

Why are the arrays not the same when providing the same seed?




Aucun commentaire:

Enregistrer un commentaire