Skip to content

Commit

Permalink
Fix bc_loss calculation in ReBRAC
Browse files Browse the repository at this point in the history
  • Loading branch information
takuseno committed Aug 25, 2024
1 parent 3433de5 commit 87751da
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions d3rlpy/algos/qlearning/torch/rebrac_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ def compute_actor_loss(
reduction="min",
)
lam = 1 / (q_t.abs().mean()).detach()
bc_loss = ((batch.actions - action.squashed_mu) ** 2).mean()
bc_loss = ((batch.actions - action.squashed_mu) ** 2).sum(
dim=1, keepdim=True
)
return TD3PlusBCActorLoss(
actor_loss=lam * -q_t.mean() + self._actor_beta * bc_loss,
bc_loss=bc_loss,
actor_loss=(lam * -q_t + self._actor_beta * bc_loss).mean(),
bc_loss=bc_loss.mean(),
)

def compute_target(self, batch: TorchMiniBatch) -> torch.Tensor:
Expand Down

0 comments on commit 87751da

Please sign in to comment.