Batching Samples For Graph

The structure of the graph I’m training is fixed (same number of nodes, it’s fully connected). For each training example, I want to set the nodes and edge data of the graph to a new value. In addition, I want the training examples to be batched.

In my forward function, I’m setting the node data to be a tensor of size (Batch_size, num_nodes, feature_size) and the edge data to be (Batch_size, num_edges, feature_size).

However, I’m getting dimensionality errors as the first dimension (batch_size) doesn’t match the number of nodes or the number of edges. I’m confused about this as generally batch_size should be the first dimension.

The examples seem to batch a list of graphs. But because the structure of my graph is fixed, I don’t need to batch it.

I’m using version 0.2 (can’t upgrade since I only have cuda 8), if that makes a difference.

I’d appreciate any clarification!
Thanks

For fully connected graphs with a same number of nodes, I don’t think using DGL will bring much gain over using adjacency matrices. If you really want to use DGL for this, you will still need to create multiple graph instances for batching.

Also interested in this, but with a non-fully-connected graph. Do you have any examples of this being done with deep graph library? It seems plausible that the graph features could just have a batch dimension?

Have you checked DGL’s tutorial on graph classification? It could be helpful for your case.

Thanks @mufeili. I think this is a possible direction, but as you say, perhaps just creating a custom TF model with an adjacency matrix is the most efficient way: I have a small number of graphs, with different (sparse) feature sets.