MCPcopy Index your code
hub / github.com/GGA23/GrokFormer / generate_node_data

Function generate_node_data

preprocess_node_data.py:190–308  ·  view source on GitHub ↗
(dataset)

Source from the content-addressed store, hash-verified

188
189
190def generate_node_data(dataset):
191
192 if dataset in ['cora', 'citeseer','pubmed']:
193
194 adj, x, y = load_data(dataset)
195 adj = adj.todense()
196 x = x.todense()
197 x = feature_normalize(x)
198 e, u = eigen_decompositon(adj)
199
200 e = torch.FloatTensor(e)
201 u = torch.FloatTensor(u)
202 x = torch.FloatTensor(x)
203 y = torch.LongTensor(y)
204
205 torch.save([e, u, x, y], 'data/{}.pt'.format(dataset))
206
207 elif dataset in ['photo']:
208 data = np.load('node_raw_data/amazon_electronics_photo.npz', allow_pickle=True)
209 adj = sp.sparse.csr_matrix((data['adj_data'], data['adj_indices'], data['adj_indptr']),
210 shape=data['adj_shape']).toarray()
211 feat = sp.sparse.csr_matrix((data['attr_data'], data['attr_indices'], data['attr_indptr']),
212 shape=data['attr_shape']).toarray()
213 x = feature_normalize(feat)
214 y = data['labels']
215 e, u = eigen_decompositon(adj)
216
217 e = torch.FloatTensor(e)
218 u = torch.FloatTensor(u)
219 x = torch.FloatTensor(x)
220 y = torch.LongTensor(y)
221
222 torch.save([e, u, x, y], 'data/{}.pt'.format(dataset))
223
224 elif dataset in ['arxiv']:
225 data = DglNodePropPredDataset('ogbn-arxiv')
226 g = data[0][0]
227 g = dgl.add_reverse_edges(g)
228 g = dgl.to_simple(g)
229
230 e, u = eig_dgl_adj_sparse(g, sm=5000)
231 x = g.ndata['feat']
232 y = data[0][1]
233
234 torch.save([e, u, x, y], 'data/arxiv.pt')
235
236 elif dataset in ['penn']:
237 g, x, y = load_fb100_dataset()
238 g = dgl.add_reverse_edges(g)
239 g = dgl.to_simple(g)
240
241 e, u = eig_dgl_adj_sparse(g, sm=3000, lm=3000)
242
243 torch.save([e, u, x, y], 'data/penn.pt')
244
245 elif dataset in ['physics']:
246 datasets = Coauthor(root='./data', name='physics', transform=T.NormalizeFeatures())
247 data = datasets[0]

Callers 1

Calls 5

load_dataFunction · 0.85
feature_normalizeFunction · 0.85
eigen_decompositonFunction · 0.85
eig_dgl_adj_sparseFunction · 0.85
load_fb100_datasetFunction · 0.85

Tested by

no test coverage detected