(self, actions: th.Tensor, gaussian_actions: Optional[th.Tensor] = None)
| 141 | return self |
| 142 | |
| 143 | def log_prob(self, actions: th.Tensor, gaussian_actions: Optional[th.Tensor] = None) -> th.Tensor: |
| 144 | # Inverse tanh |
| 145 | if gaussian_actions is None: |
| 146 | gaussian_actions = th.clamp(actions, min=-1.0 + self.eps, max=1.0 - self.eps) |
| 147 | gaussian_actions = 0.5 * (gaussian_actions.log1p() - (-gaussian_actions).log1p()) |
| 148 | |
| 149 | # Log likelihood for a Gaussian distribution |
| 150 | log_prob = self.distribution.log_prob(gaussian_actions) |
| 151 | log_prob = sum_independent_dims(log_prob) |
| 152 | |
| 153 | # sb3 correction |
| 154 | # log_prob -= th.sum(th.log(1 - actions ** 2 + self.eps), dim=1) |
| 155 | # spinning-up correction |
| 156 | log_prob -= (2*(np.log(2) - gaussian_actions - F.softplus(-2*gaussian_actions))).sum(axis=1) |
| 157 | return log_prob |
| 158 | |
| 159 | def entropy(self) -> Optional[th.Tensor]: |
| 160 | return None |
nothing calls this directly
no test coverage detected