165a86f1ab91c86828e55b3ca62030569e1c2c61,rllib/models/torch/torch_action_dist.py,TorchSquashedGaussian,_squash,#TorchSquashedGaussian#Any#,215

Before Change


    def _squash(self, raw_values):
        // Make sure raw_values are not too high/low (such that tanh would
        // return exactly 1.0/-1.0, which would lead to +/-inf log-probs).
        return (torch.clamp(
            torch.tanh(raw_values),
            -1.0 + SMALL_NUMBER,
            1.0 - SMALL_NUMBER) + 1.0) / 2.0 * (self.high - self.low) + \
                self.low

    def _unsquash(self, values):
        return atanh((values - self.low) / (self.high - self.low) * 2.0 - 1.0)

After Change



    def _squash(self, raw_values):
        // Returned values are within [low, high] (including `low` and `high`).
        squashed = ((torch.tanh(raw_values) + 1.0) / 2.0) * \
            (self.high - self.low) + self.low
        return torch.clamp(squashed, self.low, self.high)

    def _unsquash(self, values):
        normed_values = (values - self.low) / (self.high - self.low) * 2.0 - \
                        1.0
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: ray-project/ray
Commit Name: 165a86f1ab91c86828e55b3ca62030569e1c2c61
Time: 2020-04-19
Author: sven@anyscale.io
File Name: rllib/models/torch/torch_action_dist.py
Class Name: TorchSquashedGaussian
Method Name: _squash


Project Name: ray-project/ray
Commit Name: 165a86f1ab91c86828e55b3ca62030569e1c2c61
Time: 2020-04-19
Author: sven@anyscale.io
File Name: rllib/models/tf/tf_action_dist.py
Class Name: SquashedGaussian
Method Name: _squash


Project Name: chainer/chainerrl
Commit Name: f3e6d24b244ba2743842c50cd7b58ea1d310b54b
Time: 2019-05-07
Author: muupan@gmail.com
File Name: chainerrl/distribution.py
Class Name: SquashedGaussianDistribution
Method Name: sample