The PPO implementation in this repository uses a specialized actor-critic loss function.
Value Loss
The value loss uses a clipped objective to prevent large updates to the value function:
value_losses = jnp.square(value - targets)
value_losses_clipped = jnp.square(value_pred_clipped - targets)
value_loss = 0.5 * jnp.maximum(value_losses, value_losses_clipped).mean()
Actor Loss (Drift-based)
Instead of a standard PPO ratio loss, this implementation uses a drift-based approach with DPO_ALPHA and DPO_BETA parameters to regularize the policy update based on the advantage (gae). It calculates a drift term using nn.relu and nn.tanh to stabilize training.
Total Loss
The total loss is a weighted sum of the actor loss, value loss, and entropy:
total_loss = loss_actor + config["VF_COEF"] * value_loss - config["ENT_COEF"] * entropy