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())
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())
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())
def graph_b(): R.manual_seed(731) return R.uniform(5, low=-2, high=2)
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())
def graph_b(): R.manual_seed(731) return R.uniform(5) + R.gaussian(5)