How to use the ogb.nodeproppred.PygNodePropPredDataset function in ogb

To help you get started, we’ve selected a few ogb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GraphSAINT / GraphSAINT / data / open_graph_benchmark / ogbn_converter.py View on Github external
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)

ogb

Open Graph Benchmark

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages