Editing
Ai Natural Sciences
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Predicting molecular properties with a graph neural network:''' <syntaxhighlight lang="python"> from torch_geometric.data import Data, DataLoader from torch_geometric.nn import GCNConv, global_mean_pool import torch import torch.nn.functional as F from rdkit import Chem from rdkit.Chem import AllChem def mol_to_graph(smiles: str): """Convert a SMILES string to a PyG graph.""" mol = Chem.MolFromSmiles(smiles) if mol is None: return None # Node features: atomic number, degree, formal charge, aromaticity node_features = [] for atom in mol.GetAtoms(): node_features.append([ atom.GetAtomicNum(), atom.GetDegree(), atom.GetFormalCharge(), int(atom.GetIsAromatic()), ]) # Edge index (bonds) edges = [] for bond in mol.GetBonds(): i, j = bond.GetBeginAtomIdx(), bond.GetEndAtomIdx() edges.extend([[i, j], [j, i]]) # undirected β bidirectional x = torch.tensor(node_features, dtype=torch.float) edge_index = torch.tensor(edges, dtype=torch.long).t().contiguous() return Data(x=x, edge_index=edge_index) class MolecularGNN(torch.nn.Module): def __init__(self, node_features=4, hidden=128, output=1): super().__init__() self.conv1 = GCNConv(node_features, hidden) self.conv2 = GCNConv(hidden, hidden) self.conv3 = GCNConv(hidden, hidden) self.fc = torch.nn.Linear(hidden, output) def forward(self, data): x, edge_index, batch = data.x, data.edge_index, data.batch x = F.relu(self.conv1(x, edge_index)) x = F.relu(self.conv2(x, edge_index)) x = F.relu(self.conv3(x, edge_index)) x = global_mean_pool(x, batch) # Graph-level representation return self.fc(x) # Predict property (e.g., solubility, toxicity) # Example: train on QM9 molecular property dataset # from torch_geometric.datasets import QM9 # dataset = QM9(root='data/QM9') </syntaxhighlight> ; AI in natural sciences: application map : '''Biology''' β AlphaFold (protein structure), ESMFold, protein language models (ESM-2) : '''Chemistry''' β GNN for property prediction, diffusion for molecule generation, retrosynthesis : '''Drug discovery''' β Target identification, ADMET prediction, de novo drug design, DiffDock : '''Climate''' β GraphCast (weather forecasting), ClimateBench, climate emulators : '''Materials''' β Crystal structure prediction (GNoME, MEGNet), property optimization : '''Astronomy''' β Gravitational wave detection, galaxy classification, dark matter mapping : '''Physics''' β PINNs for PDE solving, neural operators (FNO), scientific simulation surrogate models </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information