pyg-team/pytorch_geometric

Provide a helper for easier batching

Open

#70 opened on Jan 10, 2019

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Python (3,514 forks)batch import
2 - Priority P2featurehelp wantedloader

Repository metrics

Stars
 (19,985 stars)
PR merge metrics
 (Avg merge 35d 1h) (14 merged PRs in 30d)

Description

DataLoader are handy in some situations however they do not cover all potential use cases. For now, I only found the following way of handling batches without them. Would it be possible to have a nice helper in native torch for this?

def forward(self, x, edge_index):
        batch_size, n_size = x.shape[:2]
        batch = [torch_geometric.data.Data(x=t, edge_index=edge_index) for t in x]
        batch = torch_geometric.data.Batch.from_data_list(batch)
        x = self.net(batch.x, batch.edge_index).view(batch_size, n_size, 1)
        return x

Contributor guide