What problem does it solve?
This Skill provides a comprehensive set of tools for building and training graph neural networks (GNNs) using PyTorch, addressing the challenges of working with graph-structured data.
Core Features & Use Cases
- Graph Data Structures: Efficiently represent and manipulate graph data with built-in data structures.
- GNN Layers: Implement a wide range of GNN layers including GCN, GAT, SAGE, GIN, and more.
- Mini-Batch Training: Scale GNN training to large graphs using mini-batch strategies.
- Heterogeneous Graphs: Handle multi-type nodes and edges with ease.
- Use Case: Ideal for tasks like node classification, graph classification, link prediction, and more, where the data is naturally represented as a graph.
Quick Start
Use the torch-geometric skill to build a simple GCN model for node classification:
import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv
class GCN(torch.nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels):
super().__init__()
self.conv1 = GCNConv(in_channels, hidden_channels)
self.conv2 = GCNConv(hidden_channels, out_channels)
def forward(self, x, edge_index):
x = self.conv1(x, edge_index).relu()
x = F.dropout(x, p=0.5, training=self.training)
x = self.conv2(x, edge_index)
return x