[RLlib] SquashedGaussians should throw error when entropy or kl are called. (#13126)

This commit is contained in:
Sven Mika
2021-01-07 15:07:35 +01:00
committed by GitHub
parent 82c54c67ee
commit bcaff63909
2 changed files with 16 additions and 0 deletions
+8
View File
@@ -335,6 +335,14 @@ class SquashedGaussian(TFActionDistribution):
axis=-1)
return log_prob
@override(ActionDistribution)
def entropy(self) -> TensorType:
raise ValueError("Entropy not defined for SquashedGaussian!")
@override(ActionDistribution)
def kl(self, other: ActionDistribution) -> TensorType:
raise ValueError("KL not defined for SquashedGaussian!")
def _squash(self, raw_values: TensorType) -> TensorType:
# Returned values are within [low, high] (including `low` and `high`).
squashed = ((tf.math.tanh(raw_values) + 1.0) / 2.0) * \
+8
View File
@@ -243,6 +243,14 @@ class TorchSquashedGaussian(TorchDistributionWrapper):
torch.log(1 - unsquashed_values_tanhd**2 + SMALL_NUMBER), dim=-1)
return log_prob
@override(TorchDistributionWrapper)
def entropy(self) -> TensorType:
raise ValueError("Entropy not defined for SquashedGaussian!")
@override(TorchDistributionWrapper)
def kl(self, other: ActionDistribution) -> TensorType:
raise ValueError("KL not defined for SquashedGaussian!")
def _squash(self, raw_values: TensorType) -> TensorType:
# Returned values are within [low, high] (including `low` and `high`).
squashed = ((torch.tanh(raw_values) + 1.0) / 2.0) * \