d8a80f6272
이름만 다른(표기 변형) [[위키링크]]를 대상 문서의 canonical 제목으로 치환해 끊겼던 1,200개 링크를 연결. 제목/파일명 정규화 일치만 적용하고 별칭 매칭은 과병합 위험으로 제외(애매성 가드). 원본은 _link_reconcile_backup/ 에 백업. 도구: Datacollect/scripts/link_reconcile_apply.mjs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
8.5 KiB
8.5 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-gnn | Graph Neural Networks (GNN) | 10_Wiki/Topics | verified | self |
|
none | A | 0.97 | applied |
|
2026-05-10 | pending |
|
Graph Neural Networks (GNN)
매 한 줄
"매 graph 의 의 의 message passing". 매 node + edge + global feature. 매 GCN (Kipf 2017), GAT, GraphSAGE, GIN, message-passing framework. 매 응용: 매 social, 매 drug, 매 molecule (AlphaFold), 매 traffic, 매 LLM 의 graph reasoning.
매 핵심
매 task
- Node classification: 매 단일 node label.
- Link prediction: 매 edge 의 의 likelihood.
- Graph classification: 매 entire graph.
- Graph regression.
- Generation: 매 graph generative.
매 layer family
- GCN (Kipf 2017): 매 spectral / message passing.
- GAT: 매 attention.
- GraphSAGE: 매 sampled neighborhood.
- GIN (Xu 2019): 매 most expressive.
- Transformer-based: GraphTransformer, Graphormer.
- Message Passing NN (general).
매 modern
- Geometric DL (Bronstein).
- Equivariant GNN (E(3), SE(3)).
- AlphaFold-3 (geometric deep learning).
- GNN + LLM (graph reasoning).
매 응용
- Social network: 매 fraud, recommendation.
- Molecule: 매 drug, materials.
- Knowledge graph: 매 reasoning.
- Traffic: 매 ETA prediction.
- Recommender.
- Combinatorial opt (TSP, scheduling).
💻 패턴
GCN (PyG)
import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv
class GCN(torch.nn.Module):
def __init__(self, in_feat, hidden, n_classes):
super().__init__()
self.conv1 = GCNConv(in_feat, hidden)
self.conv2 = GCNConv(hidden, n_classes)
def forward(self, x, edge_index):
x = F.relu(self.conv1(x, edge_index))
x = F.dropout(x, p=0.5, training=self.training)
return self.conv2(x, edge_index)
GAT (attention)
from torch_geometric.nn import GATConv
class GAT(torch.nn.Module):
def __init__(self, in_feat, hidden, n_heads=8):
super().__init__()
self.conv1 = GATConv(in_feat, hidden, heads=n_heads, dropout=0.6)
self.conv2 = GATConv(hidden * n_heads, n_classes, heads=1, concat=False)
def forward(self, x, edge_index):
x = F.elu(self.conv1(x, edge_index))
return self.conv2(x, edge_index)
GraphSAGE (sampling)
from torch_geometric.nn import SAGEConv
class GraphSAGE(torch.nn.Module):
def __init__(self, in_feat, hidden, out_feat):
super().__init__()
self.conv1 = SAGEConv(in_feat, hidden, aggr='mean')
self.conv2 = SAGEConv(hidden, out_feat, aggr='mean')
Custom MessagePassing
from torch_geometric.nn import MessagePassing
class CustomConv(MessagePassing):
def __init__(self, in_feat, out_feat):
super().__init__(aggr='mean')
self.lin = torch.nn.Linear(in_feat, out_feat)
def forward(self, x, edge_index):
x = self.lin(x)
return self.propagate(edge_index, x=x)
def message(self, x_j):
return x_j # 매 from neighbor
def update(self, aggr_out):
return aggr_out
Graph classification (read-out)
from torch_geometric.nn import global_mean_pool
class GraphClassifier(torch.nn.Module):
def __init__(self):
super().__init__()
self.conv1 = GCNConv(in_feat, 64)
self.conv2 = GCNConv(64, 64)
self.classifier = torch.nn.Linear(64, n_classes)
def forward(self, x, edge_index, batch):
x = F.relu(self.conv1(x, edge_index))
x = F.relu(self.conv2(x, edge_index))
x = global_mean_pool(x, batch) # 매 graph-level
return self.classifier(x)
Link prediction
import torch.nn as nn
class LinkPredictor(nn.Module):
def __init__(self):
super().__init__()
self.encoder = GCN(...)
self.decoder = lambda src, dst: (src * dst).sum(-1) # 매 dot product
def forward(self, x, edge_index, edge_label_index):
z = self.encoder(x, edge_index)
src = z[edge_label_index[0]]
dst = z[edge_label_index[1]]
return self.decoder(src, dst)
Sampling for large graphs (NeighborLoader)
from torch_geometric.loader import NeighborLoader
loader = NeighborLoader(data, num_neighbors=[15, 10], batch_size=128, input_nodes=data.train_mask)
for batch in loader:
out = model(batch.x, batch.edge_index)
loss = F.cross_entropy(out[:batch.batch_size], batch.y[:batch.batch_size])
Heterogeneous (HeteroData)
from torch_geometric.data import HeteroData
data = HeteroData()
data['user'].x = user_feats
data['movie'].x = movie_feats
data['user', 'rates', 'movie'].edge_index = rate_edges
from torch_geometric.nn import to_hetero
model = to_hetero(model, data.metadata())
Equivariant GNN (E(n)-EGNN)
class EGNN(MessagePassing):
def __init__(self, dim):
super().__init__(aggr='mean')
self.edge_mlp = nn.Sequential(nn.Linear(2*dim+1, dim), nn.SiLU(), nn.Linear(dim, dim))
self.coord_mlp = nn.Linear(dim, 1)
def forward(self, x, pos, edge_index):
return self.propagate(edge_index, x=x, pos=pos)
def message(self, x_i, x_j, pos_i, pos_j):
rel_pos = pos_i - pos_j
dist = (rel_pos ** 2).sum(-1, keepdim=True)
edge_feat = self.edge_mlp(torch.cat([x_i, x_j, dist], -1))
coord_msg = rel_pos * self.coord_mlp(edge_feat)
return edge_feat, coord_msg
Drug discovery (molecule)
from torch_geometric.datasets import MoleculeNet
dataset = MoleculeNet(root='data', name='ESOL')
# 매 atom-level features + bond edges → solubility
Knowledge graph (TransE)
class TransE(nn.Module):
def __init__(self, n_entities, n_relations, dim):
super().__init__()
self.entity_emb = nn.Embedding(n_entities, dim)
self.relation_emb = nn.Embedding(n_relations, dim)
def score(self, h, r, t):
return -(self.entity_emb(h) + self.relation_emb(r) - self.entity_emb(t)).norm(dim=-1)
Graph Transformer (Graphormer)
class GraphTransformer(nn.Module):
def __init__(self, dim, n_heads=8):
super().__init__()
self.attn = nn.MultiheadAttention(dim, n_heads)
self.spatial_bias = nn.Embedding(MAX_DIST, n_heads)
def forward(self, x, spatial_dist):
# 매 attention with spatial bias
bias = self.spatial_bias(spatial_dist)
attn_out, _ = self.attn(x, x, x, attn_bias=bias)
return attn_out
GNN explainer
from torch_geometric.explain import Explainer, GNNExplainer
explainer = Explainer(
model=model, algorithm=GNNExplainer(epochs=200),
explanation_type='model', node_mask_type='attributes',
edge_mask_type='object',
)
explanation = explainer(data.x, data.edge_index, target=label)
매 결정 기준
| 상황 | Architecture |
|---|---|
| Default | GCN |
| Heterogeneous | HeteroData + GAT |
| Large graph | GraphSAGE + sampling |
| Most expressive | GIN |
| Spatial / molecule | EGNN / SchNet |
| Graph-level | + global pooling |
| Knowledge graph | TransE / RotatE |
| Long-range | GraphTransformer / Graphormer |
기본값: 매 PyG + 매 GCN/GAT baseline + 매 sampling for large + 매 EGNN for geometry + 매 explainer.
🔗 Graph
- 부모: Deep Learning · Graph_Theory
- 변형: GCN · GAT · GIN
- 응용: Recommender-Systems · Knowledge-Graphs
- Adjacent: AlphaFold
🤖 LLM 활용
언제: 매 graph data. 매 social. 매 molecule. 매 KG. 언제 X: 매 sequence / image (use Transformer / CNN).
❌ 안티패턴
- Over-smoothing (deep GNN): 매 nodes converge.
- No batching for large: 매 OOM.
- Ignore edge features: 매 info lose.
- Default attention 의 always: 매 simple sometimes better.
- No scaling for many classes: 매 long-tail.
🧪 검증 / 중복
- Verified (Kipf GCN 2017, Xu GIN 2019, PyG/DGL docs, AlphaFold).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-04-26 | GNN auto |
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — GCN/GAT/SAGE + 매 PyG / hetero / EGNN / link / explainer code |