3a3916adbe18066f8fdf854ae1c9edbb28103ec3,hyperspherical_vae/distributions/von_mises_fisher.py,VonMisesFisher,__sample_w_rej,#VonMisesFisher#Any#,60

Before Change


        // using Taylor approximation with a smooth swift from 10 < scale < 11
        // to avoid numerical errors for large scale
        b_app = (self.__m - 1) / (4 * self.scale)
        s = torch.min(torch.max(torch.Tensor([0.]), self.scale - 10), torch.Tensor([1.]))
        b = b_app * s + b_true * (1 - s)

        a = (self.__m - 1 + 2 * self.scale + c) / 4
        d = (4 * a * b) / (1 + b) - (self.__m - 1) * math.log(self.__m - 1)

After Change


    
    def __sample_w_rej(self, shape):
        //c = torch.sqrt((4 * (self.scale ** 2)) + (self.__m - 1) ** 2)
        c = self.scale.type(torch.float64) * torch.sqrt(4 + ((self.__m - 1) ** 2) / (self.scale.type(torch.float64) ** 2))
        b = (-2 * self.scale.type(torch.float64) + c) / (self.__m - 1)
        a = (self.__m - 1 + 2 * self.scale.type(torch.float64) + c) / 4
        d = (4 * a * b) / (1 + b) - (self.__m - 1) * math.log(self.__m - 1)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: nicola-decao/s-vae-pytorch
Commit Name: 3a3916adbe18066f8fdf854ae1c9edbb28103ec3
Time: 2018-07-28
Author: nicola.decao@student.uva.nl
File Name: hyperspherical_vae/distributions/von_mises_fisher.py
Class Name: VonMisesFisher
Method Name: __sample_w_rej


Project Name: pytorch/fairseq
Commit Name: 1c6679294848f303a361cba7b306b760e299bd9c
Time: 2019-09-30
Author: sarthak_garg@apple.com
File Name: fairseq/sequence_scorer.py
Class Name: SequenceScorer
Method Name: generate