15434d0f74feb6735402bf7688b6d9540497d43a,src/spn/algorithms/layerwise/layers.py,Product,sample,#Product#Any#Any#,234

Before Change



        // If this is a root node
        if indices is None:
            return torch.zeros(n, 1)

        // Repeat the parent indices, e.g. [0, 2, 3] -> [0, 0, 2, 2, 3, 3] depending on the cardinality
        sample_indices = torch.repeat_interleave(indices, repeats=self.cardinality, dim=1)

After Change


        

        // If this is a root node
        if context is None:
            if self.num_repetitions == 1:
                // If there is only a single repetition, create new sampling context
                return SamplingContext(
                    n=n,
                    parent_indices=torch.zeros(n, 1, dtype=int, device=self.__device),
                    repetition_indices=torch.zeros(n, dtype=int, device=self.__device),
                )
            else:
                raise Exception(
                    "Cannot start sampling from Product layer with num_repetitions > 1 and no context given."
                )
        else:
            // Repeat the parent indices, e.g. [0, 2, 3] -> [0, 0, 2, 2, 3, 3] depending on the cardinality
            indices = torch.repeat_interleave(context.parent_indices, repeats=self.cardinality, dim=1)

            // Remove padding
            if self._pad:
                indices = indices[:, : -self._pad]

            context.parent_indices = indices
            return context

    def __repr__(self):
        return "Product(in_features={}, cardinality={}, out_shape={})".format(
            self.in_features, self.cardinality, self.out_shape
        )
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: SPFlow/SPFlow
Commit Name: 15434d0f74feb6735402bf7688b6d9540497d43a
Time: 2020-04-03
Author: steven.lang.mz@gmail.com
File Name: src/spn/algorithms/layerwise/layers.py
Class Name: Product
Method Name: sample


Project Name: dmlc/dgl
Commit Name: 18a26fcfb1983af7fba69db9bdce7ba5e6a9945f
Time: 2020-06-29
Author: VoVAllen@users.noreply.github.com
File Name: python/dgl/data/graph_serialize.py
Class Name:
Method Name: load_labels


Project Name: dmlc/dgl
Commit Name: 18a26fcfb1983af7fba69db9bdce7ba5e6a9945f
Time: 2020-06-29
Author: VoVAllen@users.noreply.github.com
File Name: python/dgl/data/graph_serialize.py
Class Name:
Method Name: load_graphs