def testErrorOnWrongTimeStepSpecWhenCreatingAgent(self): wrong_time_step_spec = ts.time_step_spec( array_spec.ArraySpec([2], np.float32)) action_spec = tensor_spec.BoundedTensorSpec([1], tf.float32, -1, 1) with self.assertRaisesRegex( TypeError, 'time_step_spec has to contain TypeSpec'): tf_agent.TFAgent(wrong_time_step_spec, action_spec, None, None, None)
def testErrorOnWrongActionSpecWhenCreatingAgent(self): time_step_spec = ts.time_step_spec( tensor_spec.TensorSpec([2], tf.float32)) wrong_action_spec = array_spec.BoundedArraySpec([1], np.float32, -1, 1) with self.assertRaisesRegex( TypeError, 'action_spec has to contain BoundedTensorSpec'): tf_agent.TFAgent(time_step_spec, wrong_action_spec, None, None, None)
def testErrorOnWrongActionSpecWhenCreatingAgent(self): time_step_spec = ts.time_step_spec( tensor_spec.TensorSpec([2], tf.float32)) wrong_action_spec = array_spec.BoundedArraySpec([1], np.float32, -1, 1) with self.assertRaises(TypeError) as cm: tf_agent.TFAgent(time_step_spec, wrong_action_spec, None, None, None) self.assertStartsWith(six.text_type(cm.exception), 'action_spec has to contain BoundedTensorSpec')