deepsnap icon indicating copy to clipboard operation
deepsnap copied to clipboard

Inductive Link Prediction graph copying

Open drewdrewdrewdrew opened this issue 2 years ago • 0 comments

Hi, in the Inductive Link Prediction Split section of this colab notebook, I see we're making copies of the input graph to help set up the train / val / test splits.

This technique is echoed in this example as well but it seems to be more explicitly implemented to support learning on multiple graphs.

I'd like to use DeepSNAP's functionalities to manage train/val/test splits for edge prediction on a large graph (100MM+ nodes) and it seems strange/undesirable to have to create copies in this way. Is this truly the case or am I missing something? Does DeepSNAP allow inductive learning on single graphs?

import networkx as nx
from copy import deepcopy
from deepsnap.graph import Graph
from deepsnap.dataset import GraphDataset



run_transductive = False
n_copies_for_inductive = 10


myG = nx.complete_graph(50)
snap_graph = Graph(myG)


if not run_transductive:
    graphs = [copy.deepcopy(snap_graph) for _ in range(n_copies_for_inductive)]
else:
    graphs = [snap_graph]
    
    
dataset = GraphDataset(
    graphs,
    task='link_pred',
    edge_negative_sampling_ratio=1,
    edge_train_mode='disjoint'
)    

train, val, test = dataset.split(transductive=run_transductive, split_ratio=[0.85, 0.05, 0.1])

drewdrewdrewdrew avatar Jul 15 '22 11:07 drewdrewdrewdrew