def testComputeActionFeasibility(self): constraint_net = DummyNet(self._observation_spec, self._action_spec) quantile_constraint = constraints.QuantileConstraint( self._time_step_spec, self._action_spec, constraint_network=constraint_net) init_op = quantile_constraint.initialize() if not tf.executing_eagerly(): with self.cached_session() as sess: common.initialize_uninitialized_variables(sess) self.assertIsNone(sess.run(init_op)) observation = tf.constant([[1, 2], [3, 4]], dtype=tf.float32) feasibility_prob = quantile_constraint(observation) self.assertAllGreaterEqual(self.evaluate(feasibility_prob), 0.0) self.assertAllLessEqual(self.evaluate(feasibility_prob), 1.0)
def testCreateConstraint(self): constraint_net = DummyNet(self._observation_spec, self._action_spec) constraints.QuantileConstraint( self._time_step_spec, self._action_spec, constraint_network=constraint_net)