Skip to content

Commit

Permalink
[refactor] Reduce dimension of continuous ent coef (#4725)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ervin T authored Dec 9, 2020
1 parent 71e075d commit a2c419d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions ml-agents/mlagents/trainers/sac/optimizer_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ def __init__(self, policy: TorchPolicy, trainer_params: TrainerSettings):
requires_grad=True,
)
_cont_log_ent_coef = torch.nn.Parameter(
torch.log(
torch.as_tensor([self.init_entcoef] * self._action_spec.continuous_size)
),
requires_grad=True,
torch.log(torch.as_tensor([self.init_entcoef])), requires_grad=True
)
self._log_ent_coef = TorchSACOptimizer.LogEntCoef(
discrete=_disc_log_ent_coef, continuous=_cont_log_ent_coef
Expand Down Expand Up @@ -426,7 +423,7 @@ def sac_entropy_loss(
)
# We update all the _cont_ent_coef as one block
entropy_loss += -1 * ModelUtils.masked_mean(
torch.mean(_cont_ent_coef) * target_current_diff, loss_masks
_cont_ent_coef * target_current_diff, loss_masks
)

return entropy_loss
Expand Down

0 comments on commit a2c419d

Please sign in to comment.