python2和torch7中的随机排列

时间:2016-11-15 19:00:31

标签: python numpy random permutation torch

我一直在和咖啡和火炬一起工作,当我遇到一些有趣的东西时,试图复制一些实验。当使用相同的种子时,python numpy.random.permuationtorch.randperm似乎会产生不同的值。

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> 

为什么在提供相同的种子时数组不相同?

0 个答案:

没有答案