pythontensorflowmachine-learninggraph-neural-network

spektral.datasets.citation.load_data() not found


I am trying to use the CoRA dataset to train a graph neural network on tensorflow and it's my first time using Spektral.

After some research on the internet, I learnt that there's supposed to be a useful loader function that comes with Spektral for me to load this benchmark dataset so I attempted to implement it:

adj,features,labels,train_mask,val_mask,test_mask=spektral.datasets.citation.load_data(dataset_name="cora")

Then I got this:

AttributeError: module 'spektral.datasets.citation' has no attribute 'load_data'

I checked the Spektral documentation and I didn't find the load_data loader function so I think there's an update or something.

It would be helpful if anybody can provide any alternatives or a possible explanation for the error.


Solution

  • I solved the problem myself after some more research. For Spektral version 1.1.0, I think this does the job of the loader function in terms of using the CoRA dataset:

    cora_dataset = spektral.datasets.citation.Citation(name='cora')
    test_mask = cora_dataset.mask_te
    train_mask = cora_dataset.mask_tr
    val_mask = cora_dataset.mask_va
    graph = cora_dataset.graphs[0]
    features = graph.x
    adj = graph.a
    labels = graph.y