def test_scan(self): with self.test_session(): set_seed(42) op = tf.scan(lambda a, x: a + x, tf.constant([2.0, 3.0, 1.0])) self.assertAllClose(op.eval(), [2.0, 5.0, 6.0]) self.assertAllClose(copy(op).eval(), [2.0, 5.0, 6.0])
def test_scan_random(self): with self.test_session() as session: set_seed(1234) op = tf.scan(lambda a, x: a + x, tf.random_normal([3])) copy_op = copy(op) result = session.run([copy_op, copy_op, op, op]) self.assertAllClose(result[0], result[1]) self.assertAllClose(result[2], result[3])
def test_dict_rv_rv(self): with self.test_session(): set_seed(325135) x = Normal(mu=0.0, sigma=0.1) y = tf.constant(1.0) z = x * y qx = Normal(mu=10.0, sigma=0.1) z_new = copy(z, {x: qx}) self.assertGreater(z_new.eval(), 5.0)
def test_dict_tensor_rv(self): with self.test_session(): set_seed(95258) x = Normal(mu=0.0, sigma=0.1) y = tf.constant(1.0) z = x * y qx = Normal(mu=10.0, sigma=0.1) z_new = copy(z, {x.value(): qx}) self.assertGreater(z_new.eval(), 5.0)
def test_dict_rv_tensor(self): with self.test_session(): set_seed(289362) x = Normal(mu=0.0, sigma=0.1) y = tf.constant(1.0) z = x * y qx = Normal(mu=10.0, sigma=0.1) z_new = copy(z, {x: qx.value()}) self.assertGreater(z_new.eval(), 5.0)