Chapter 1: Why Do We Need GNNs in Materials Science?
Grasp intuitively the advantages of representing molecules and crystals as "graphs." Understand the limitations of conventional descriptors and the problems that GNNs should solve through concrete examples.
💡 Supplement: A graph is like "intersections (atoms) and roads (bonds)." Picture messages propagating to neighbors like "a rumor spreading."
The AI innovation that understands the "shape" of molecules and materials
Learning Objectives
By reading this chapter, you will be able to:
- ✅ Understand the three limitations of conventional material descriptors (vector representations)
- ✅ Learn the fundamentals of graph theory (vertices, edges, adjacency matrix)
- ✅ Master how to represent molecules and materials as graphs
- ✅ Explain why GNNs are considered important in materials science
- ✅ Learn about real-world GNN success stories (OC20, QM9, Materials Project)
- ✅ Visualize graph structures in Python
Reading time: 20-25 min Code examples: 6 Exercises: 3
1.1 Limitations of Conventional Methods: Why Vector Representations Are Insufficient
What Is a Material Descriptor?
In materials science, molecules and crystals are converted into numerical vectors called "material descriptors" so that they can be handled by machine learning.
Example: Vector representation of a water molecule (H₂O)
# Composition-based descriptor
water_descriptor = [
2.0, # Number of H atoms
1.0, # Number of O atoms
2.55, # Mean electronegativity
0.66, # Mean atomic radius (Å)
18.01 # Molecular weight
]
This approach is simple and fast, but it has serious limitations.
Limitation 1: Loss of Structural Information
Problem: The arrangement of atoms and their bonding relationships are lost
Example: Isomers of butane (C₄H₁₀)
# n-butane and isobutane have the same composition
n_butane = [
4, # Number of C atoms
10, # Number of H atoms
2.5 # Mean number of valence electrons
]
iso_butane = [
4, # Number of C atoms (same)
10, # Number of H atoms (same)
2.5 # Mean number of valence electrons (same)
]
Same vector → different compounds!
n-butane: C-C-C-C (linear)
isobutane: C
|
C-C-C (branched)
Difference in boiling point: - n-butane: -0.5°C - isobutane: -11.7°C
Conventional descriptors cannot explain this 11.2°C difference.
Limitation 2: Ignoring Long-Range Interactions
Problem: Distances and angles between atoms are not considered
Example: Protein folding
import numpy as np
# Amino acid sequence (1D vector)
sequence = [1, 5, 3, 8, 2, ...] # Sequence of amino acid IDs
# The actual 3D structure has more than 10^300 possibilities
# In vector representation, one sequence → infinite 3D shapes
Example of catalytic activity: - The active site (where the reaction occurs) is determined by the 3D spatial arrangement - Even with the same sequence, activity can vary by 100x if the spatial arrangement differs
Limitation 3: Asymmetry of Substituents
Problem: Molecular symmetry/asymmetry cannot be represented
Example: Drug enantiomers
L-dopa (Parkinson's disease drug)
COOH
|
H-C-NH₂ (left-handed form)
|
CH₂-...
D-dopa (no effect, potentially toxic)
COOH
|
H₂N-C-H (right-handed form, mirror image)
|
CH₂-...
The same in vector representation:
L_dopa = [9, 11, 4, 2] # C, H, O, N counts
D_dopa = [9, 11, 4, 2] # Same vector
Yet their biological activity is exactly opposite.
Summary of the Limitations of Conventional Methods
| Limitation | Description | Impact |
|---|---|---|
| Loss of structural information | Bonding relationships are lost | Cannot distinguish isomers |
| Ignoring long-range interactions | 3D spatial arrangement unknown | Failure in catalytic activity prediction |
| Asymmetry of substituents | Cannot distinguish enantiomers | Drug safety issues |
Conclusion: To understand the "shape" of materials and molecules, graph representation is necessary.
1.2 Fundamentals of Graph Theory: A New Language for Molecules and Materials
What Is a Graph?
Definition:
A graph is a set of vertices (nodes) and edges.
Mathematical notation: $$ G = (V, E) $$
- $V$: set of vertices
- $E$: set of edges
Graph Representation of a Water Molecule (H₂O)
Representation in Python:
# Using the NetworkX library
import networkx as nx
import matplotlib.pyplot as plt
# Create the graph
G = nx.Graph()
# Add vertices (atoms)
G.add_node('O', element='O', mass=16.0)
G.add_node('H1', element='H', mass=1.0)
G.add_node('H2', element='H', mass=1.0)
# Add edges (bonds)
G.add_edge('O', 'H1', bond_type='single')
G.add_edge('O', 'H2', bond_type='single')
# Visualization
pos = {'O': (0, 0), 'H1': (-1, -1), 'H2': (1, -1)}
nx.draw(
G, pos, with_labels=True,
node_color='lightblue',
node_size=2000,
font_size=16,
font_weight='bold'
)
plt.title('Graph Representation of the H₂O Molecule')
plt.show()
Output:
O
/ \
/ \
H1 H2
Adjacency Matrix
This is a representation for handling graphs on a computer.
Definition: $$ A_{ij} = \begin{cases} 1 & \text{if edge between node } i \text{ and } j \ 0 & \text{otherwise} \end{cases} $$
Adjacency matrix of H₂O:
import numpy as np
# Vertex order: [O, H1, H2]
adjacency_matrix = np.array([
[0, 1, 1], # O: bonded to H1 and H2
[1, 0, 0], # H1: bonded to O
[1, 0, 0] # H2: bonded to O
])
print(adjacency_matrix)
Output:
[[0 1 1]
[1 0 0]
[1 0 0]]
Key points: - Symmetric matrix (for undirected graphs) - Diagonal elements are 0 (no self-loops) - Sparse matrix (most elements are 0)
A More Complex Molecule: Methane (CH₄)
# Graph of methane
methane = nx.Graph()
# Carbon (center)
methane.add_node('C', element='C', mass=12.0)
# Four hydrogen atoms
for i in range(1, 5):
methane.add_node(f'H{i}', element='H', mass=1.0)
methane.add_edge('C', f'H{i}', bond_type='single')
# Adjacency matrix
A = nx.adjacency_matrix(methane).todense()
print(f"Adjacency matrix of methane:\n{A}")
Output:
Adjacency matrix of methane:
[[0 1 1 1 1] # C: bonded to 4 H atoms
[1 0 0 0 0] # H1
[1 0 0 0 0] # H2
[1 0 0 0 0] # H3
[1 0 0 0 0]] # H4
Types of Graphs
| Graph Type | Description | Example in Materials Science |
|---|---|---|
| Undirected graph | Edges have no direction | Covalent bonds (H-O-H) |
| Directed graph | Edges have direction | Coordinate bonds (Lewis base → acid) |
| Weighted graph | Edges have weights | Bond energy |
| Multigraph | Multiple edges allowed | Double bonds (C=O) |
1.3 Graph Representation of Molecules and Materials
Molecular Graph
Definition: - Vertex (Node): atom - Edge: chemical bond - Node features: atomic number, charge, hybridization orbital - Edge features: bond order, bond length, bond angle
Example: Ethanol (C₂H₅OH)
import rdkit
from rdkit import Chem
from rdkit.Chem import Draw
# Generate a graph from SMILES
ethanol_smiles = 'CCO'
mol = Chem.MolFromSmiles(ethanol_smiles)
# Extract graph information
print("=== Graph Structure of Ethanol ===")
print(f"Number of atoms (vertices): {mol.GetNumAtoms()}")
print(f"Number of bonds (edges): {mol.GetNumBonds()}")
# Information for each atom (vertex)
for atom in mol.GetAtoms():
print(f"Atom {atom.GetIdx()}: {atom.GetSymbol()}, "
f"valence={atom.GetTotalValence()}, "
f"hybridization={atom.GetHybridization()}")
# Information for each bond (edge)
for bond in mol.GetBonds():
print(f"Bond {bond.GetIdx()}: "
f"{bond.GetBeginAtomIdx()}-{bond.GetEndAtomIdx()}, "
f"type={bond.GetBondType()}")
Output:
=== Graph Structure of Ethanol ===
Number of atoms (vertices): 9
Number of bonds (edges): 8
Atom 0: C, valence=4, hybridization=SP3
Atom 1: C, valence=4, hybridization=SP3
Atom 2: O, valence=2, hybridization=SP3
Atom 3: H, valence=1, hybridization=S
...
Bond 0: 0-1, type=SINGLE
Bond 1: 1-2, type=SINGLE
Bond 2: 0-3, type=SINGLE
...
Graph Representation of Crystal Structures (Periodic Graph)
Crystals are represented as periodic graphs.
from pymatgen.core import Structure, Lattice
# NaCl crystal structure
lattice = Lattice.cubic(5.64) # Lattice constant 5.64 Å
structure = Structure(
lattice,
species=['Na', 'Cl'],
coords=[[0, 0, 0], [0.5, 0.5, 0.5]]
)
print("=== Graph Representation of NaCl Crystal ===")
print(f"Number of atoms in the unit cell: {len(structure)}")
# Get neighboring atoms (cutoff=3.0 Å)
neighbors = structure.get_neighbors(structure[0], r=3.0)
print(f"Number of neighbors of the Na atom (within 3 Å): {len(neighbors)}")
for neighbor in neighbors:
print(f" {neighbor.species_string} at {neighbor.nn_distance:.2f} Å")
Output:
=== Graph Representation of NaCl Crystal ===
Number of atoms in the unit cell: 2
Number of neighbors of the Na atom (within 3 Å): 6
Cl at 2.82 Å
Cl at 2.82 Å
Cl at 2.82 Å
Cl at 2.82 Å
Cl at 2.82 Å
Cl at 2.82 Å
Visualization of the graph structure:
Advantages of Graph Representation
Comparison with conventional vector representation:
# ===== Conventional vector representation =====
# Ethanol (C₂H₅OH)
ethanol_vector = [
2, # Number of C atoms
6, # Number of H atoms
1, # Number of O atoms
2.3 # Mean electronegativity
]
# Isopropanol (C₃H₇OH) - an isomer but indistinguishable
isopropanol_vector = [
3, # Number of C atoms
8, # Number of H atoms
1, # Number of O atoms
2.3 # Mean electronegativity (nearly the same)
]
# ===== Graph representation =====
# Ethanol
ethanol_graph = {
'nodes': ['C', 'C', 'O', 'H', 'H', 'H', 'H', 'H', 'H'],
'edges': [(0,1), (1,2), (0,3), (0,4), (0,5),
(1,6), (1,7), (2,8)],
'structure': 'C-C-O-H (linear)'
}
# Isopropanol
isopropanol_graph = {
'nodes': ['C', 'C', 'C', 'O', 'H', 'H', 'H', 'H',
'H', 'H', 'H', 'H'],
'edges': [(0,1), (1,2), (1,3), (0,4), (0,5), (0,6),
(2,7), (2,8), (2,9), (3,10), ...],
'structure': '(CH₃)-CH(OH)-CH₃ (branched)'
}
Clear distinction is possible!
| Feature | Vector Representation | Graph Representation |
|---|---|---|
| Distinguishing isomers | ❌ Impossible | ✅ Possible |
| Spatial arrangement | ❌ Ignored | ✅ Preserved |
| Bonding information | ❌ Lost | ✅ Complete |
| Long-range interactions | ❌ Difficult | ✅ Possible |
| Interpretability | ✅ High | ✅ High |
1.4 Advantages of GNNs: Why They Are Attracting Attention in Materials Science
Advantage 1: End-to-End Feature Learning
Conventional approach (manual feature design):
# Step 1: Experts design features (weeks to months)
features = calculate_descriptors(molecule)
# [electronegativity, atomic radius, ionization energy, ...]
# Step 2: Machine learning model
model.fit(features, target)
GNN approach (automatic feature learning):
# Just input the graph
gnn_model.fit(graph, target)
# The GNN automatically learns the optimal features
Results: - Development time: months → days - Performance: can even exceed expert-designed features
Advantage 2: Transfer Learning
Pre-trained models can be leveraged.
from torch_geometric.nn import GCN
# Step 1: Pre-train on large-scale data (1M molecules)
pretrained_model = GCN.from_pretrained('molecular-gnn-base')
# Step 2: Fine-tune on small-scale data (100 molecules)
pretrained_model.finetune(
your_small_dataset,
epochs=10
)
Effects: - Required data: 10,000 samples → 100 samples - Accuracy: 80% → 92%
Advantage 3: Interpretability
GNNs can explain "why they made a given prediction."
# Visualize which atoms are important
atom_importance = gnn_model.explain(molecule)
# Highlight atoms that contribute to catalytic activity
visualize_importance(molecule, atom_importance)
Example: Catalyst design - Identification of active sites - Optimization of substituents - Understanding of the mechanism
1.5 Success Stories: How GNNs Changed Materials Science
Case Study 1: OC20 - Accelerating Catalyst Discovery
Project: Open Catalyst 2020 (Meta AI Research) Goal: Efficient search for clean-energy catalysts
Dataset: - Scale: 1.3M DFT calculations - Target: Adsorption energy on catalyst surfaces - Search space: 10^12 combinations
GNN models: SchNet, DimeNet++, GemNet
Results:
Conventional method (DFT calculation): 24 hours per material
GNN prediction: 0.01 seconds per material (2.4 million times faster)
Accuracy: MAE = 0.43 eV (practical level)
Catalysts discovered: 10 types (experimentally validated)
Code example (simplified):
from torch_geometric.datasets import OC20
from torch_geometric.nn import SchNet
# Load the dataset
dataset = OC20(root='./data/oc20', split='train')
# SchNet model
model = SchNet(
hidden_channels=128,
num_filters=128,
num_interactions=6,
num_gaussians=50,
cutoff=6.0
)
# Training (simplified)
for data in dataset[:1000]:
pred_energy = model(data.z, data.pos, data.batch)
# ...loss computation, optimization
Impact: - Discovery of CO2-reduction catalysts - Improved efficiency of hydrogen production - Paper: Chanussot et al. (2021), ACS Catalysis
Case Study 2: QM9 - The Standard for Molecular Property Prediction
Dataset: QM9 - 134k organic molecules Properties: HOMO-LUMO gap, dipole moment, heat capacity, etc.
GNN model: MPNN (Message Passing Neural Network)
Results:
| Property | Conventional (RF) | GNN (MPNN) | Improvement |
|---|---|---|---|
| HOMO-LUMO gap | MAE=0.25 eV | 0.04 eV | 84% |
| Dipole moment | MAE=0.45 D | 0.03 D | 93% |
| Heat capacity | MAE=1.2 cal/mol·K | 0.04 | 97% |
Code example:
from torch_geometric.datasets import QM9
from torch_geometric.nn import GCNConv, global_mean_pool
# Dataset
dataset = QM9(root='./data/qm9')
print(f"Number of molecules: {len(dataset)}")
print(f"Number of properties: {dataset.num_tasks}")
# A simple GNN
class SimpleGNN(torch.nn.Module):
def __init__(self):
super().__init__()
self.conv1 = GCNConv(11, 64) # 11-dimensional atom features
self.conv2 = GCNConv(64, 64)
self.lin = torch.nn.Linear(64, 1)
def forward(self, data):
x, edge_index, batch = data.x, data.edge_index, data.batch
# Graph convolution
x = F.relu(self.conv1(x, edge_index))
x = F.relu(self.conv2(x, edge_index))
# Graph-level prediction
x = global_mean_pool(x, batch)
x = self.lin(x)
return x
model = SimpleGNN()
Paper: Gilmer et al. (2017), ICML
Case Study 3: Materials Project - Crystal Property Prediction
Database: Materials Project (140k+ materials) Tasks: Formation energy, band gap, and elastic modulus prediction
GNN model: CGCNN (Crystal Graph Convolutional Neural Network)
Results:
Formation energy prediction:
- Conventional method (RF): MAE = 0.15 eV/atom
- CGCNN: MAE = 0.039 eV/atom (74% improvement)
Computation time:
- DFT calculation: 10-100 hours/material
- CGCNN prediction: 0.1 seconds/material (3.6 million times faster)
Code example:
from pymatgen.core import Structure
import torch
# Load the crystal structure
structure = Structure.from_file('POSCAR')
# Convert to a graph
def structure_to_graph(structure, cutoff=5.0):
"""
Convert a crystal structure to a graph
"""
nodes = [] # Atom features
edges = [] # Bonding information
for i, site in enumerate(structure):
# Node features (atomic number, coordinates, etc.)
nodes.append([
site.specie.Z, # Atomic number
site.x, site.y, site.z # Coordinates
])
# Search for neighboring atoms
neighbors = structure.get_neighbors(site, r=cutoff)
for neighbor in neighbors:
edges.append([i, neighbor.index])
return {
'nodes': torch.tensor(nodes),
'edges': torch.tensor(edges)
}
graph = structure_to_graph(structure)
print(f"Number of nodes: {len(graph['nodes'])}")
print(f"Number of edges: {len(graph['edges'])}")
Impact: - Discovery of new Li-ion battery materials - Optimization of solar-cell materials - Paper: Xie & Grossman (2018), Physical Review Letters
Comparison of Success Stories
| Project | Target | Data Scale | Speedup | Accuracy Improvement |
|---|---|---|---|---|
| OC20 | Catalysts | 1.3M | 2.4 million× | MAE 0.43 eV |
| QM9 | Organic molecules | 134k | 1000× | 84-97% improvement |
| Materials Project | Crystals | 140k+ | 3.6 million× | 74% improvement |
Common features: - Adoption of graph representation - End-to-end learning - Order-of-magnitude speedup - Practical-level accuracy
1.6 Column: The History of Graph Theory and Materials Science
Euler's Seven Bridges Problem (1736)
The origin of graph theory is the "Königsberg bridge problem" posed by Leonhard Euler.
Problem: Can all seven bridges be crossed in a single stroke (without retracing)?
Euler's answer: Impossible (because not every vertex has an even degree)
Applications to materials science: - Determining molecular connectivity - Searching reaction pathways - Analyzing crystal symmetry
Chemical Graph Theory (1950s onward)
Arthur Cayley (1857): The first molecular graph representation Harry Wiener (1947): The Wiener Index (a molecular descriptor)
Example calculation of the Wiener Index:
import networkx as nx
# Graph of a butane molecule
butane = nx.path_graph(4) # C-C-C-C
# Wiener Index = sum of shortest distances between all pairs
wiener_index = sum(
dict(nx.all_pairs_shortest_path_length(butane))[i][j]
for i in range(4)
for j in range(i+1, 4)
)
print(f"Wiener Index: {wiener_index}")
# Output: 10 = (1+2+3) + (1+2) + (1)
Influence on modern methods: - Theoretical foundations of GNNs - Graph kernel methods - Quantification of molecular similarity
1.7 Chapter Summary
What We Learned
-
Limitations of conventional methods - Loss of structural information (cannot distinguish isomers) - Ignoring long-range interactions (3D arrangement unknown) - Asymmetry of substituents (cannot distinguish enantiomers)
-
Fundamentals of graph theory - Graph = vertices + edges - Numerical representation via the adjacency matrix - Graph representation of molecules and crystals
-
Advantages of GNNs - End-to-end feature learning - Transfer learning (high accuracy with little data) - Interpretability (identifying important atoms)
-
Success stories - OC20 (catalysts, 2.4 million times faster) - QM9 (molecular properties, 84-97% accuracy improvement) - Materials Project (crystals, 74% accuracy improvement)
Key Points
- ✅ Materials and molecules can be represented as graphs
- ✅ Graph representation carries more information than conventional vector representation
- ✅ GNNs are AI that understand structure
- ✅ They achieve order-of-magnitude speedups in the real world
- ✅ They are becoming a standard tool in chemistry and materials science
To the Next Chapter
In Chapter 2, we will learn the fundamental theory of GNNs: - The mechanism of message passing - Differences among GCN, GAT, and GraphSAGE - Materials-science-specialized GNNs such as SchNet and DimeNet - Mathematical background and implementation basics
Chapter 2: Fundamental Theory of GNNs →
Exercises
Exercise 1 (Difficulty: easy)
Determine whether the following statements are true or false.
- A graph's adjacency matrix is always a symmetric matrix
- Molecular isomers can be distinguished with conventional vector representation
- GNNs can utilize bonding information between atoms
Hint
- Consider the difference between undirected and directed graphs - Review "Limitation 1" in Section 1.2 - Recall the advantages of graph representationSample Answer
**Answer**: 1. **False** - Symmetric only for undirected graphs. Directed graphs are asymmetric. 2. **False** - Vector representation cannot distinguish isomers (same composition → same vector) 3. **True** - GNNs can directly use edge (bond) information **Explanation**: On statement 1:# Example of a directed graph (asymmetric)
import numpy as np
A = np.array([
[0, 1, 0],
[0, 0, 1],
[0, 0, 0]
])
# A ≠ A^T (differs from its transpose)
On statement 2:
- n-butane and isobutane have the same composition (C₄H₁₀)
- Vector representation: [4, 10] → indistinguishable
- Graph representation: different connectivity → distinguishable
On statement 3:
- GNNs receive bonding information via `edge_index`
- Message passing aggregates information from neighboring atoms
Exercise 2 (Difficulty: medium)
Create a graph representation of the following molecule (propane, C₃H₈) and compute its adjacency matrix.
Structure: CH₃-CH₂-CH₃
Atom order: C1, C2, C3, H1, H2, H3, H4, H5, H6, H7, H8
Requirements: 1. Create the graph with NetworkX 2. Compute the adjacency matrix 3. Visualize the graph
Hint
- Carbon has four bonds - Build the C1-C2-C3 backbone first - Add hydrogens at the ends **Functions to use**: - `nx.Graph()`: create a graph - `G.add_edge(u, v)`: add an edge - `nx.adjacency_matrix(G)`: adjacency matrixSample Answer
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
# Create the graph
G = nx.Graph()
# Carbon backbone (C1-C2-C3)
G.add_edge('C1', 'C2')
G.add_edge('C2', 'C3')
# Add hydrogens
# Three hydrogens on C1
G.add_edge('C1', 'H1')
G.add_edge('C1', 'H2')
G.add_edge('C1', 'H3')
# Two hydrogens on C2
G.add_edge('C2', 'H4')
G.add_edge('C2', 'H5')
# Three hydrogens on C3
G.add_edge('C3', 'H6')
G.add_edge('C3', 'H7')
G.add_edge('C3', 'H8')
# Adjacency matrix
A = nx.adjacency_matrix(G).todense()
print("Adjacency matrix (11×11):")
print(A)
# Visualization
pos = nx.spring_layout(G, seed=42)
nx.draw(
G, pos, with_labels=True,
node_color='lightblue',
node_size=1500,
font_size=10,
font_weight='bold',
edge_color='gray'
)
plt.title('Graph Representation of Propane (C₃H₈)')
plt.show()
**Output**:
Adjacency matrix (11×11):
[[0 1 0 1 1 1 0 0 0 0 0] # C1
[1 0 1 0 0 0 1 1 0 0 0] # C2
[0 1 0 0 0 0 0 0 1 1 1] # C3
[1 0 0 0 0 0 0 0 0 0 0] # H1
...
]
**Explanation**:
1. **Number of vertices**: 11 (C×3 + H×8)
2. **Number of edges**: 10 (C-C bonds×2 + C-H bonds×8)
3. **Degrees**:
- C1: 4 (C2 + H1 + H2 + H3)
- C2: 4 (C1 + C3 + H4 + H5)
- C3: 4 (C2 + H6 + H7 + H8)
- Each H: 1
**Extension tasks**:
- Try creating a graph of propene (C₃H₆, with a double bond)
- Reflect bond order (single=1, double=2) in the adjacency matrix
Exercise 3 (Difficulty: hard)
For the following scenario, propose how GNNs can be utilized.
Scenario: You are a researcher at a pharmaceutical company, searching for candidate compounds for a new COVID-19 drug.
Background: - Known inhibitors: 1,000 compounds (with activity data) - Candidate compound database: 1 billion compounds - Goal: Find compounds that bind to the viral protease (protein) - Constraints: 1 million yen per experimental compound, 1 million hours/compound
Tasks: 1. Propose an efficient search strategy using GNNs 2. Explain the required data and model architecture 3. Estimate the expected effects (cost reduction, time savings)
Hint
**Approach**: 1. Pre-train on known data 2. Screen 1 billion compounds with a GNN 3. Experimentally validate the top candidates **Considerations**: - Leverage transfer learning - Trade-off between prediction accuracy and search coverage - Use of experimental feedback (active learning)Sample Answer
**Proposal: GNN-Driven Staged Screening** ### Step 1: Data Preparation and Model Trainingfrom torch_geometric.nn import GCNConv, global_max_pool
import torch.nn.functional as F
class DrugGNN(torch.nn.Module):
def __init__(self):
super().__init__()
# Graph convolution layers
self.conv1 = GCNConv(75, 128) # 75-dimensional atom features
self.conv2 = GCNConv(128, 128)
self.conv3 = GCNConv(128, 64)
# Fully connected layers (inhibitory activity prediction)
self.lin1 = torch.nn.Linear(64, 32)
self.lin2 = torch.nn.Linear(32, 1)
def forward(self, data):
x, edge_index, batch = data.x, data.edge_index, data.batch
# Graph convolution
x = F.relu(self.conv1(x, edge_index))
x = F.relu(self.conv2(x, edge_index))
x = F.relu(self.conv3(x, edge_index))
# Graph-level prediction
x = global_max_pool(x, batch)
x = F.relu(self.lin1(x))
x = self.lin2(x)
return x # Inhibitory activity score
# Training (1,000 known compounds)
model = DrugGNN()
# ... training loop
### Step 2: Large-Scale Screening
# Predict 1 billion compounds in parallel
def screen_compounds(model, compound_library, batch_size=1000):
"""
Screening of a large-scale compound library
"""
predictions = []
for i in range(0, len(compound_library), batch_size):
batch = compound_library[i:i+batch_size]
# Convert to graphs
graphs = [smiles_to_graph(smiles) for smiles in batch]
# Predict
scores = model.predict(graphs)
predictions.extend(scores)
# Select the top 1,000 compounds
top_candidates = sorted(
zip(compound_library, predictions),
key=lambda x: x[1],
reverse=True
)[:1000]
return top_candidates
# Run
top_1000 = screen_compounds(model, billion_compounds)
### Step 3: Experimental Validation and Feedback
# Active learning
for iteration in range(10):
# Experimentally validate the top 100 compounds
experimental_results = run_experiments(top_1000[:100])
# Retrain the model (add new data)
model.finetune(experimental_results)
# Re-screen the remaining compounds
top_1000 = screen_compounds(
model,
remaining_compounds
)
---
### Expected Effects
**Cost reduction**:
Conventional method (random screening):
- Number of experiments: 10,000 compounds
- Cost: 10,000 × 1 million yen = 10 billion yen
- Time: 10,000 × 10,000 hours = 100 million hours ≈ 11,000 years
GNN method:
- Computational screening: 1 billion compounds (1 week, 10 million yen)
- Experimental validation: 1,000 compounds (1 billion yen, 10,000 hours ≈ 1 year)
- Total cost: 1.1 billion yen (91% reduction)
- Total time: 1 year (99.99% reduction)
**Accuracy improvement**:
- Hit rate: 0.1% → 10% (100x improvement)
- Further improvement by leveraging pre-trained models (e.g., ChemBERTa)
---
### Additional Considerations
**Risk management**:
1. **False Positive**
- Even high GNN predictions may fail in experiments
- Countermeasure: Uncertainty estimation (Bayesian GNN)
2. **Data bias**
- Bias toward structures similar to known compounds
- Countermeasure: Diversity-aware search
3. **Patents and regulations**
- Check the intellectual property of candidate compounds
- Toxicity and side-effect prediction
**Implementation details**:
- Hardware: 8 GPUs (1 billion compounds in 1 week)
- Software: PyTorch Geometric, RDKit, DeepChem
- Databases: PubChem, ZINC, ChEMBL
---
### Skills Learned
Through this exercise:
- ✅ Concretized the industrial application of GNNs
- ✅ Analyzed the trade-offs among cost, time, and accuracy
- ✅ Designed a staged screening strategy
- ✅ Understood the importance of active learning
References
-
Gilmer, J. et al. (2017). "Neural Message Passing for Quantum Chemistry." ICML. DOI: https://arxiv.org/abs/1704.01212
-
Chanussot, L. et al. (2021). "Open Catalyst 2020 (OC20) Dataset and Community Challenges." ACS Catalysis, 11, 6059-6072. DOI: https://doi.org/10.1021/acscatal.0c04525
-
Xie, T. & Grossman, J. C. (2018). "Crystal Graph Convolutional Neural Networks for an Accurate and Interpretable Prediction of Material Properties." Physical Review Letters, 120, 145301. DOI: https://doi.org/10.1103/PhysRevLett.120.145301
-
Schütt, K. T. et al. (2017). "SchNet: A continuous-filter convolutional neural network for modeling quantum interactions." NeurIPS. DOI: https://arxiv.org/abs/1706.08566
-
Wu, Z. et al. (2020). "A Comprehensive Survey on Graph Neural Networks." IEEE Transactions on Neural Networks and Learning Systems, 32(1), 4-24. DOI: https://doi.org/10.1109/TNNLS.2020.2978386
Navigation
Next Chapter
Chapter 2: Fundamental Theory of GNNs →
Series Table of Contents
← Back to Series Table of Contents
Author Information
Author: AI Terakoya Content Team Created: 2025-10-17 Version: 1.0
Revision history: - 2025-10-17: v1.0 Initial release
Feedback: - GitHub Issues: [repository URL]/issues - Email: yusuke.hashimoto.b8@tohoku.ac.jp
License: Creative Commons BY 4.0
In Chapter 2, let's learn the internal mechanisms of GNNs in detail!