mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-11-18 09:54:10 +00:00
Fix exp_ln computation
This commit is contained in:
parent
9b3b34c9c4
commit
7f34108ed6
1 changed files with 5 additions and 4 deletions
|
|
@ -272,10 +272,11 @@ class StateDependentNoiseDistribution(Distribution):
|
||||||
if self.use_expln:
|
if self.use_expln:
|
||||||
# From SDE paper, it allows to keep variance
|
# From SDE paper, it allows to keep variance
|
||||||
# above zero and prevent it from growing too fast
|
# above zero and prevent it from growing too fast
|
||||||
if log_std <= 0:
|
below_threshold = th.exp(log_std) * (log_std <= 0)
|
||||||
std = th.exp(log_std)
|
# Avoid NaN: zeros values that are below zero
|
||||||
else:
|
safe_log_std = log_std * (log_std > 0) + self.epsilon
|
||||||
std = th.log(log_std + 1.0) + 1.0
|
above_threshold = (th.log1p(safe_log_std) + 1.0) * (log_std > 0)
|
||||||
|
std = below_threshold + above_threshold
|
||||||
else:
|
else:
|
||||||
# Use normal exponential
|
# Use normal exponential
|
||||||
std = th.exp(log_std)
|
std = th.exp(log_std)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue