Batching with graph as input and sentences as output

Hi! I have a problem where my input is graph and the output is sentences. I’m using GCN as an encoder and then pool the features of all nodes. I’m using LSTM as a decoder. My question is what is the most efficient way to do batching in this case as the graphs have different number of nodes and the sentences are of variable lengths too. Each graph correspond to one sentence in target.

My approach:
I’m thinking of padding the sentences with the max length of a sentence in a batch. For the graphs, I have node embeddings as stacked word embeddings of all nodes of a graph (each node has one word) and I have an adjacency matrix for the graph. I’m thinking of padding the node embeddings with the zeros according to the maximum number of nodes for graphs in a batch and use padding again for the adjacency matrix.

If you haven’t already looked at PyTorch Geometric, it’s a great tool for graph neural networks. It allows you to seamlessly batch data of varying sizes.