def testStatefulStandardNormal(self): """Tests that op 'StatefulStandardNormal' still works. """ shape = constant_op.constant([4, 7]) dtype = dtypes.float64 seed = 1234 algorithm = random.RNG_ALG_PHILOX state = random._make_state_from_seed(seed, algorithm) with ops.device("/device:CPU:0"): var1 = variables.Variable(np.concatenate( (np.array([algorithm], dtype=random.STATE_TYPE), state), axis=None), dtype=random.STATE_TYPE) var2 = variables.Variable(state, dtype=random.STATE_TYPE) for _ in range(100): t1 = gen_stateful_random_ops.stateful_standard_normal( var1.handle, shape, dtype) t2 = gen_stateful_random_ops.stateful_standard_normal_v2( var2.handle, algorithm, shape, dtype) self.assertAllEqual(t1, t2)
def standard_normal(self, shape, dtype=dtypes.float32): return gen_stateful_random_ops.stateful_standard_normal( self.state.handle, shape, dtype)