1187f93b53b14ed61704c0f07d618c47822f180a,gpytorch/random_variables/categorical_random_variable.py,CategoricalRandomVariable,sample,#CategoricalRandomVariable#,24

Before Change


        p = random.random()
        cmf_lt = self._cumulative_mass_function.ge(p)
        for i,v in enumerate(cmf_lt):
            if v == 1:
                return torch.LongTensor([i])

    def num_categories(self):
        return len(self.mass_function)

After Change


        return math.log(self.mass_function[i])

    def sample(self):
        return torch.multinomial(self.mass_function, 1)

    def num_categories(self):
        return len(self.mass_function)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: cornellius-gp/gpytorch
Commit Name: 1187f93b53b14ed61704c0f07d618c47822f180a
Time: 2017-07-12
Author: gpleiss@gmail.com
File Name: gpytorch/random_variables/categorical_random_variable.py
Class Name: CategoricalRandomVariable
Method Name: sample


Project Name: chainer/chainerrl
Commit Name: ed592270c7bb5c10e02474d4134ac2b05e7c8b67
Time: 2017-01-24
Author: muupan@gmail.com
File Name: chainerrl/envs/abc.py
Class Name: ABC
Method Name: step


Project Name: BindsNET/bindsnet
Commit Name: 996804c052aca22d54a5206aab5c6f33552b16f7
Time: 2019-10-05
Author: hi@sharath.pro
File Name: bindsnet/pipeline/action.py
Class Name:
Method Name: select_softmax