[Blog] Batched Graph Classification with DGL

Graph classification is an important problem with applications across many fields – bioinformatics, chemoinformatics, social network analysis, urban computing and cyber-security. Applying graph neural networks to this problem has been a popular approach recently (Ying et al., 2018, Cangea et al., 2018, Knyazev et al., 2018, Bianchi et al., 2019, Liao et al., 2019, Gao et al., 2019).

This is a companion discussion topic for the original entry at https://www.dgl.ai/blog/2019/01/25/batch.html
1 Like

Feel free to leave any feedback and comments about this blog. There are more blogs on the way.

If possible, can you post links to Arxiv as link to abstract, not on PDF? thank you

Can you also add the RSS or Atom feed to the blog?

Thank you

For the time being, you can find the links to arXiv/OpenReview abstract below:

Thank you very much - I already found them :slight_smile:
I only wanted to make small “usability” suggestion - because sometimes, authors upload the newer version, and direct PDF linking doesn’t reflect this.

1 Like

I see. We will fix this. Thank you for the kind suggestions.

@alexott you could now subscribe using this feed url: https://www.dgl.ai/feed.xml . If you’d like to subscribe only certain category, use https://www.dgl.ai/feed/blog.xml and replace “blog” with the category you like.

Thank you very much!


I’m adapting this code to my own graph classification task, in which each node has some features. Here is an example for a batch of 32 graphs from a DataLoader:

DGLGraph(num_nodes=116, num_edges=68,
         ndata_schemes={'coords': Scheme(shape=(2,), dtype=torch.float32), 'perimeter': Scheme(shape=(1,), dtype=torch.float32), 'kind': Scheme(shape=(5,), dtype=torch.float32)}

Hence the following newbie question: does the tutorial code leverage these features during learning or does it only use the graph topologies?

The tutorial code uses a synthetic dataset where we do not have node features and we use node degrees for node features instead. In tasks like molecule property prediction it’s quite common to perform featurization for nodes and edges first.

1 Like

Hello, in this tutorial, you use MiniGCDataset, but I’d like to know how to make a dataset with my own data?

@tangocean In case you have not found it, here is the source file of the dataset. Basically, to make a dataset for dgl is the same as to make one for PyTorch, where you essentially need to define two methods __len__(self) and __getitem__(self, idx).

Hi, I too am new to graph classification and am trying to leverage node features in a gcn.
Could you give a brief guide on how to use these features? or point me in the direction of a resource?

Specifically, using multiple features per node. ie; i would like to use 7 features per node, however receive the error:
DGLError: Expect number of features to match number of nodes (len(u)). Got 552230 and 78890 instead.

In your case, the node features can be viewed as a 78890 x 7 matrix where row i of the matrix corresponds to the features of the ith node. It seems that by accident you have flattened the features into a 1 x 552230 matrix. Could you please post the code you used for feature assignment?

thanks! yes I realised I had flattered the features, all fixed and working now.
thanks again.

how can i use t-sne for visualization.
i couldn’t find any code about it in this dgl documentation.
please help me

You can use t-sne from scikit-learn, which is what I did for the tutorial.

1 Like

thank you but i don’t know how can i access embedding file and i where do embedding save can you send me your code if it’s possible my mail is drmehrdadmehrvarz@gmail.com i really need this for understanding some important notes