Exemple #1
0
 def generate_normalization(self, norm="sym"):
     if self.__normed__:
         return
     degrees = (self.row_ptr[1:] - self.row_ptr[:-1]).float()
     if norm == "sym":
         edge_norm = torch.pow(degrees, -0.5).to(self.device)
         edge_norm[torch.isinf(edge_norm)] = 0
         self.__out_norm__ = self.__in_norm__ = edge_norm.view(-1, 1)
     elif norm == "row":
         edge_norm = torch.pow(degrees, -1).to(self.device)
         edge_norm[torch.isinf(edge_norm)] = 0
         self.__out_norm__ = None
         self.__in_norm__ = edge_norm.view(-1, 1)
     elif norm == "col":
         self.row, _, _ = csr2coo(self.row_ptr, self.col, self.weight)
         self.weight = row_normalization(self.num_nodes, self.col, self.row, self.weight)
     else:
         raise NotImplementedError
     self.__normed__ = norm
Exemple #2
0
 def edge_index(self):
     if self.row is None:
         self.row, _, _ = csr2coo(self.row_ptr, self.col, self.weight)
     return torch.stack([self.row, self.col])
Exemple #3
0
 def edge_index(self):
     if self.row is None:
         self.row, _, _ = csr2coo(self.row_ptr, self.col, self.weight)
     return self.row, self.col