Chapter 48

গ্রাফ নিউরাল নেটওয়ার্ক

Graph Neural Networks
🕸️ Graph-ও Deep Learning-এ আসুক
Graph Neural Networks — nodes ও edges-এর উপর কাজ করে। Social network, molecule, knowledge graph, recommendation — সর্বত্র GNN।

মূল ধারণা — Message Passing

প্রতি node তার প্রতিবেশীদের থেকে "message" সংগ্রহ করে, aggregate করে, এবং নিজের embedding update করে। K layer পর K-hop information ধারণ করে।

h_v^(k+1) = UPDATE( h_v^(k), AGG({ h_u^(k) : u ∈ N(v) }) )

প্রধান architecture

  • GCN: normalized neighbor average।
  • GraphSAGE: sampling-based, scalable।
  • GAT: attention দিয়ে weighted aggregation।
  • GIN: WL-test power, graph classification-এ শক্তিশালী।

PyTorch Geometric

import torch
from torch_geometric.nn import GCNConv
from torch_geometric.datasets import Planetoid

data = Planetoid(root='/tmp/Cora', name='Cora')[0]

class GCN(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.c1 = GCNConv(data.num_features, 16)
        self.c2 = GCNConv(16, data.y.max().item()+1)
    def forward(self, x, edge_index):
        x = self.c1(x, edge_index).relu()
        return self.c2(x, edge_index)

model = GCN()
out = model(data.x, data.edge_index)

Task Types

  • Node classification: paper topic, fraud detection।
  • Link prediction: friend suggestion, drug-target।
  • Graph classification: molecule property।

প্রয়োগ

  • Drug discovery, protein folding (AlphaFold-এ GNN component)।
  • Recommendation (PinSage @ Pinterest)।
  • Traffic forecasting (Google Maps ETA)।
  • Fraud detection in transactions।
💡 কখন GNN দরকার
Data স্বাভাবিকভাবেই relational/graph হলে — না হলে regular NN-ই যথেষ্ট। Tabular data-কে জোর করে graph বানানো overkill।

সারসংক্ষেপ

✨ এই অধ্যায়ে যা শিখলাম
  • GNN = message passing on nodes/edges।
  • GCN, GraphSAGE, GAT, GIN — মূল architecture।
  • PyTorch Geometric / DGL — practical libraries।