MCPcopy
hub / github.com/dmlc/dgl / _load_graph

Method _load_graph

python/dgl/data/qm7b.py:92–106  ·  view source on GitHub ↗
(self, filename)

Source from the content-addressed store, hash-verified

90 self.graphs, self.label = self._load_graph(mat_path)
91
92 def _load_graph(self, filename):
93 data = io.loadmat(filename)
94 labels = F.tensor(data["T"], dtype=F.data_type_dict["float32"])
95 feats = data["X"]
96 num_graphs = labels.shape[0]
97 graphs = []
98 for i in range(num_graphs):
99 edge_list = feats[i].nonzero()
100 g = dgl_graph(edge_list)
101 g.edata["h"] = F.tensor(
102 feats[i][edge_list[0], edge_list[1]].reshape(-1, 1),
103 dtype=F.data_type_dict["float32"],
104 )
105 graphs.append(g)
106 return graphs, labels
107
108 def save(self):
109 """save the graph list and the labels"""

Callers 1

processMethod · 0.95

Calls 2

nonzeroMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected