If train_test_split_edges is replaced by randomlinksplit
In tutorial 6 if we use the randomlinksplit how does train_pos_edge_index get handled later in the code?
Does this line become:
train_pos_edge_index = train_data.edge_index.to(device) ?
And how is the test function redefined? If we don't have pos edges nor neg edges, then can you describe what happens to the test function?
Hiya, I was just going through the repo. In regards to newer functions, when using randomlinksplit. There is a parameter within split_labels which when =True will give you distinct "pos_edge_label" and "neg_edge_label".
After having a look at tutorial 6 , test function should look something like this:
from torch_geometric.utils import negative_sampling
def test(pos_edge_index, neg_edge_index=None):
model.eval()
with torch.no_grad():
z = model.encode(x, train_pos_edge_index)
# Generate negative samples dynamically if not provided
if neg_edge_index is None:
neg_edge_index = negative_sampling(
edge_index=train_pos_edge_index,
num_nodes=data.num_nodes,
num_neg_samples=pos_edge_index.size(1)
)
return model.test(z, pos_edge_index, neg_edge_index)
Note: train_pos_edge_index would be derived as train_data.edge_index. in case negative samples are not present you can use sampling like this.