mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-07-05 04:17:59 +00:00
evaluation_actions returns approx entropy when no analytical form is known
This commit is contained in:
parent
f262cac7ba
commit
beeea59d9b
1 changed files with 3 additions and 2 deletions
|
|
@ -612,7 +612,7 @@ class ActorCriticPolicy(BasePolicy):
|
|||
"""
|
||||
return self.get_distribution(observation).get_actions(deterministic=deterministic)
|
||||
|
||||
def evaluate_actions(self, obs: th.Tensor, actions: th.Tensor) -> Tuple[th.Tensor, th.Tensor, Optional[th.Tensor]]:
|
||||
def evaluate_actions(self, obs: th.Tensor, actions: th.Tensor) -> Tuple[th.Tensor, th.Tensor, th.Tensor]:
|
||||
"""
|
||||
Evaluate actions according to the current policy,
|
||||
given the observations.
|
||||
|
|
@ -631,7 +631,8 @@ class ActorCriticPolicy(BasePolicy):
|
|||
try:
|
||||
entropy = distribution.entropy()
|
||||
except NotImplementedError:
|
||||
entropy = None
|
||||
# When no analytical form, entropy needs to be estimated using -log_prob.mean()
|
||||
entropy = -log_prob.mean(dim=1)
|
||||
return values, log_prob, entropy
|
||||
|
||||
def get_distribution(self, obs: th.Tensor) -> Distribution:
|
||||
|
|
|
|||
Loading…
Reference in a new issue