deeplearning4j icon indicating copy to clipboard operation
deeplearning4j copied to clipboard

SameDiff random ops not respecting Nd4j RNG seed

Open AlexDBlack opened this issue 4 years ago • 0 comments

    @Test
    public void testUniformDtype2(){
        for( int i=0; i<10; i++ ) {
            Nd4j.getRandom().setSeed(12345);
            SameDiff sd = SameDiff.create();
            SDVariable shape = sd.constant("shape", Nd4j.createFromArray(1, 10));
            SDVariable out = sd.random.uniform(0, 10, shape, DataType.FLOAT);
            INDArray arr = out.eval();
            System.out.println(arr);
        }
    }

Should be the same each run, but isn't...

[[    1.2411,    8.0639,    4.5653,    1.7953,    7.4027,    2.6210,    1.6064,    6.4674,    7.8534,    6.9427]]
[[    3.8222,    0.1412,    7.3603,    8.2204,    9.6595,    8.0606,    3.9113,    2.7194,    1.2074,    6.5769]]
[[    6.9485,    0.9763,    4.2340,    2.8028,    0.2806,    3.0710,    3.2902,    9.8070,    6.0038,    5.7212]]
[[    2.9113,    4.7237,    4.5446,    8.4343,    7.4649,    7.2255,    9.8534,    9.1652,    6.1211,    0.3243]]
[[    0.9306,    0.1412,    1.9428,    1.5606,    8.3965,    8.0606,    1.8340,    7.7090,    4.9755,    6.5769]]
[[    9.7850,    5.5587,    3.0884,    9.2694,    3.5035,    2.2359,    9.2322,    0.8353,    4.6649,    9.4686]]
[[    1.5310,    0.9763,    0.4659,    7.7925,    6.5332,    3.0710,    1.2958,    2.0989,    7.2460,    5.7212]]
[[    4.9678,    4.7237,    1.6115,    8.4343,    5.3876,    7.2255,    7.8590,    9.1652,    1.5179,    0.3243]]
[[    3.8222,    0.1412,    8.1747,    1.5606,    9.6595,    8.0606,    9.8396,    7.7090,    1.2074,    6.5769]]
[[    2.6766,    5.5587,    0.1554,    9.2694,    0.5912,    2.2359,    7.2379,    0.8353,    0.8968,    9.4686]]

AlexDBlack avatar Mar 31 '20 12:03 AlexDBlack