コード例 #1
0
ファイル: constraints_test.py プロジェクト: woerns/agents
  def testComputeActionFeasibility(self):
    constraint_net = DummyNet(self._observation_spec, self._action_spec)

    absolute_constraint = constraints.AbsoluteConstraint(
        self._time_step_spec,
        self._action_spec,
        constraint_network=constraint_net)
    init_op = absolute_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 = absolute_constraint(observation)
    self.assertAllGreaterEqual(self.evaluate(feasibility_prob), 0.0)
    self.assertAllLessEqual(self.evaluate(feasibility_prob), 1.0)
コード例 #2
0
ファイル: constraints_test.py プロジェクト: woerns/agents
 def testCreateConstraint(self):
   constraint_net = DummyNet(self._observation_spec, self._action_spec)
   constraints.AbsoluteConstraint(
       self._time_step_spec,
       self._action_spec,
       constraint_network=constraint_net)