예제 #1
0
def test_dropout_dynamic_same_result():
    x = mge.ones(10)
    R.manual_seed(0)
    a = F.dropout(x, 0.5)
    R.manual_seed(0)
    b = F.dropout(x, 0.5)
    assert np.all(a.numpy() == b.numpy())
예제 #2
0
def test_M_dropout_static_same_result():
    m = M.Dropout(0.5)

    @jit.trace(symbolic=True)
    def graph_a(x):
        return m(x)

    @jit.trace(symbolic=True)
    def graph_b(x):
        return m(x)

    x = np.ones(10, dtype="float32")
    R.manual_seed(0)
    a = graph_a(x)
    a = a.numpy().copy()
    R.manual_seed(0)
    b = graph_b(x)
    R.manual_seed(0)  # useless
    c = graph_a(x)
    assert np.all(a == b.numpy())
    assert np.any(a != c.numpy())
예제 #3
0
def test_range_uniform_dynamic_same_result():
    R.manual_seed(0)
    a = R.uniform(5, low=-2, high=2)
    R.manual_seed(0)
    b = R.uniform(5, low=-2, high=2)
    assert np.all(a.numpy() == b.numpy())
예제 #4
0
 def graph_b():
     R.manual_seed(731)
     return R.uniform(5, low=-2, high=2)
예제 #5
0
def test_random_dynamic_same_result():
    R.manual_seed(0)
    a = R.uniform(5) + R.gaussian(5)
    R.manual_seed(0)
    b = R.uniform(5) + R.gaussian(5)
    assert np.all(a.numpy() == b.numpy())
예제 #6
0
 def graph_b():
     R.manual_seed(731)
     return R.uniform(5) + R.gaussian(5)