Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import sys
import os
import numpy as np
import scipy.sparse as sp
from tqdm import tqdm
from ogb.nodeproppred import PygNodePropPredDataset
"""
Run this script to convert the graph from the open graph benchmark format
to the GraphSAINT format.
Right now, ogbn-products and ogbn-arxiv can be converted by this script.
"""
dataset = PygNodePropPredDataset(name=sys.argv[1])
split_idx = dataset.get_idx_split()
train_idx, valid_idx, test_idx = split_idx['train'], split_idx['valid'], split_idx['test']
graph = dataset[0]
num_node = graph.y.shape[0]
# import pdb; pdb.set_trace()
save_dir = './data/'+sys.argv[1]+'/'
try:
os.mkdir(save_dir)
except OSError as error:
print(error)
# feats.npy
feats = graph.x.numpy()
np.save(save_dir+'feats.npy',feats)