Allow std logging for full and diagonal cov policies

This commit is contained in:
Dominik Moritz Roth 2022-07-15 18:46:42 +02:00
parent 74697e8773
commit f184b88f19

View File

@ -361,8 +361,12 @@ class PPO(GaussianRolloutCollectorAuxclass, OnPolicyAlgorithm):
self.logger.record( self.logger.record(
"train/std", th.exp(self.policy.log_std).mean().item()) "train/std", th.exp(self.policy.log_std).mean().item())
if hasattr(self.policy, "chol"): if hasattr(self.policy, "chol"):
self.logger.record( if len(self.policy.chol.shape) == 1:
"train/std", th.mean(th.diagonal(self.policy.chol, dim1=-2, dim2=-1)).mean().item()) self.logger.record(
"train/std", th.mean(self.policy.chol).mean().item())
else:
self.logger.record(
"train/std", th.mean(th.diagonal(self.policy.chol, dim1=-2, dim2=-1)).mean().item())
self.logger.record("train/n_updates", self.logger.record("train/n_updates",
self._n_updates, exclude="tensorboard") self._n_updates, exclude="tensorboard")