mirror of
https://github.com/wassname/ray.git
synced 2026-07-15 11:25:40 +08:00
[RLlib] SquashedGaussians should throw error when entropy or kl are called. (#13126)
This commit is contained in:
@@ -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) * \
|
||||
|
||||
@@ -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) * \
|
||||
|
||||
Reference in New Issue
Block a user