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

Method process

python/dgl/data/flickr.py:89–130  ·  view source on GitHub ↗

process raw data to graph, labels and masks

(self)

Source from the content-addressed store, hash-verified

87 )
88
89 def process(self):
90 """process raw data to graph, labels and masks"""
91 coo_adj = sp.load_npz(os.path.join(self.raw_path, "adj_full.npz"))
92 g = from_scipy(coo_adj)
93
94 features = np.load(os.path.join(self.raw_path, "feats.npy"))
95 features = F.tensor(features, dtype=F.float32)
96
97 y = [-1] * features.shape[0]
98 with open(os.path.join(self.raw_path, "class_map.json")) as f:
99 class_map = json.load(f)
100 for key, item in class_map.items():
101 y[int(key)] = item
102 labels = F.tensor(np.array(y), dtype=F.int64)
103
104 with open(os.path.join(self.raw_path, "role.json")) as f:
105 role = json.load(f)
106
107 train_mask = np.zeros(features.shape[0], dtype=bool)
108 train_mask[role["tr"]] = True
109
110 val_mask = np.zeros(features.shape[0], dtype=bool)
111 val_mask[role["va"]] = True
112
113 test_mask = np.zeros(features.shape[0], dtype=bool)
114 test_mask[role["te"]] = True
115
116 g.ndata["feat"] = features
117 g.ndata["label"] = labels
118 g.ndata["train_mask"] = generate_mask_tensor(train_mask)
119 g.ndata["val_mask"] = generate_mask_tensor(val_mask)
120 g.ndata["test_mask"] = generate_mask_tensor(test_mask)
121
122 if self._reorder:
123 self._graph = reorder_graph(
124 g,
125 node_permute_algo="rcmk",
126 edge_permute_algo="dst",
127 store_ids=False,
128 )
129 else:
130 self._graph = g
131
132 def has_cache(self):
133 graph_path = os.path.join(self.save_path, "dgl_graph.bin")

Callers

nothing calls this directly

Calls 6

from_scipyFunction · 0.85
generate_mask_tensorFunction · 0.85
reorder_graphFunction · 0.85
joinMethod · 0.45
loadMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected