967aa62a62948322d9d70e229587be1a530cde80,infcomp/modules.py,Artifact,add_one_hot_distribution,#Artifact#Any#,514

Before Change


    def add_one_hot_distribution(self, distribution):
        distribution_name = distribution.name()
        if not distribution_name in self.one_hot_distribution:
            util.log_print(colored("Polymorphing, new distribution    : " + distribution_name, "magenta", attrs=["bold"]))
            i = len(self.one_hot_distribution)
            if i >= self.one_hot_distribution_dim:
                util.log_error("one_hot_distribution overflow: {0}".format(i))
            t = util.Tensor(self.one_hot_distribution_dim).zero_()
            t.narrow(0, i, 1).fill_(1)
            self.one_hot_distribution[distribution_name] = Variable(t, requires_grad=False)

After Change


    def add_one_hot_distribution(self, distribution):
        distribution_name = distribution.name()
        if not distribution_name in self.one_hot_distribution:
            util.log_print(colored("Polymorphing, new distribution    : " + distribution_name, "magenta", attrs=["bold"]))
            i = len(self.one_hot_distribution)
            if i < self.one_hot_distribution_dim:
                t = util.Tensor(self.one_hot_distribution_dim).zero_()
                t.narrow(0, i, 1).fill_(1)
                self.one_hot_distribution[distribution_name] = Variable(t, requires_grad=False)
            else:
                util.log_warning("Overflow (collision) in one_hot_distribution. Allowed: {0}; Encountered: {1}".format(self.one_hot_distribution_dim, i + 1))
                self.one_hot_distribution[distribution_name] = random.choice(list(self.one_hot_distribution.values()))

    def move_to_cuda(self, device_id=None):
        self.on_cuda = True
        self.cuda_device_id = device_id
        self.cuda(device_id)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 22

Instances


Project Name: pyprob/pyprob
Commit Name: 967aa62a62948322d9d70e229587be1a530cde80
Time: 2017-05-13
Author: atilimgunes.baydin@gmail.com
File Name: infcomp/modules.py
Class Name: Artifact
Method Name: add_one_hot_distribution


Project Name: pyprob/pyprob
Commit Name: 967aa62a62948322d9d70e229587be1a530cde80
Time: 2017-05-13
Author: atilimgunes.baydin@gmail.com
File Name: infcomp/modules.py
Class Name: Artifact
Method Name: add_one_hot_instance


Project Name: pyprob/pyprob
Commit Name: 967aa62a62948322d9d70e229587be1a530cde80
Time: 2017-05-13
Author: atilimgunes.baydin@gmail.com
File Name: infcomp/modules.py
Class Name: Artifact
Method Name: add_one_hot_distribution


Project Name: pyprob/pyprob
Commit Name: 967aa62a62948322d9d70e229587be1a530cde80
Time: 2017-05-13
Author: atilimgunes.baydin@gmail.com
File Name: infcomp/modules.py
Class Name: Artifact
Method Name: add_one_hot_address