Class for representing a trainable constraint using a neural network.

Inherits From: BaseConstraint

This constraint class uses a neural network to compute the action feasibility. In this case, the loss function needs to be exposed for training the neural network weights, typically done by the agent that uses this constraint.

time_step_spec A TimeStep spec of the expected time_steps.
action_spec A nest of BoundedTensorSpec representing the actions.
constraint_network An instance of used to provide estimates of action feasibility. The input structure should be consistent with the observation_spec. If the constraint network is not available at construction time, it can be set later on using the constraint_network setter.
error_loss_fn A function for computing the loss used to train the constraint network. The default is tf.losses.mean_squared_error.
name Python str name of this agent. All variables in this module will fall under that name. Defaults to the class name.





View source

Computes loss for training the constraint network.

observations A batch of observations.
actions A batch of actions.
rewards A batch of rewards.
weights Optional scalar or elementwise (per-batch-entry) importance weights. The output batch loss will be scaled by these weights, and the final scalar loss is the mean of these values.
training Whether the loss is being used for training.

loss A Tensor containing the loss for the training step.


View source

Returns an op to initialize the constraint.


View source

Returns the probability of input actions being feasible.