Skip to content

Commit 9d472a1

Browse files
committed
Add config files and links to pretrained models
1 parent 4181365 commit 9d472a1

File tree

16 files changed

+168
-503
lines changed

16 files changed

+168
-503
lines changed
Lines changed: 46 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,57 @@
1-
load_model: null
2-
conf: null
3-
num_epochs: 3000
4-
batch_size: 512
5-
inference_batch_size: 512
6-
lr: 0.0007
7-
lr_patience: 5
8-
lr_min: 1.0e-07
9-
lr_factor: 0.5
10-
lr_warmup_steps: 10000
11-
early_stopping_patience: 500
12-
weight_decay: 0.0
13-
ema_alpha_y: 1.0
14-
ema_alpha_dy: 1.0
15-
ngpus: -1
16-
num_nodes: 1
17-
precision: 32
18-
log_dir: /shared/philipp/geometric/logs/equivariant_transformer-ANI1/
19-
splits: null
20-
train_size: 0.8
21-
val_size: 0.05
22-
test_size: null
23-
test_interval: 10
24-
save_interval: 10
25-
seed: 10
26-
distributed_backend: ddp
27-
num_workers: 6
28-
redirect: true
1+
activation: silu
2+
aggr: add
3+
atom_filter: -1
4+
attn_activation: silu
5+
batch_size: 2048
6+
coord_files: null
7+
cutoff_lower: 0.0
8+
cutoff_upper: 5.0
299
dataset: ANI1
30-
dataset_root: ~/data
3110
dataset_arg: null
32-
coord_files: null
11+
dataset_root: ~/data
12+
derivative: false
13+
distance_influence: both
14+
distributed_backend: ddp
15+
early_stopping_patience: 500
16+
ema_alpha_dy: 1.0
17+
ema_alpha_y: 1.0
3318
embed_files: null
19+
embedding_dimension: 128
3420
energy_files: null
35-
force_files: null
3621
energy_weight: 1.0
22+
force_files: null
3723
force_weight: 1.0
24+
inference_batch_size: 2048
25+
load_model: null
26+
log_dir: logs/
27+
lr: 0.0007
28+
lr_factor: 0.5
29+
lr_min: 1.0e-07
30+
lr_patience: 5
31+
lr_warmup_steps: 10000
32+
max_num_neighbors: 32
33+
max_z: 100
3834
model: equivariant-transformer
35+
neighbor_embedding: true
36+
ngpus: -1
37+
num_epochs: 3000
38+
num_heads: 8
39+
num_layers: 6
40+
num_nodes: 1
41+
num_rbf: 32
42+
num_workers: 6
3943
output_model: Scalar
44+
precision: 32
4045
prior_model: Atomref
41-
embedding_dimension: 128
42-
num_layers: 6
43-
num_rbf: 64
44-
activation: silu
4546
rbf_type: expnorm
46-
trainable_rbf: false
47-
neighbor_embedding: true
48-
distance_influence: both
49-
attn_activation: silu
50-
num_heads: 8
51-
derivative: false
52-
cutoff_lower: 0.0
53-
cutoff_upper: 5.0
54-
atom_filter: -1
55-
max_z: 100
56-
max_num_neighbors: 32
57-
standardize: false
47+
redirect: false
5848
reduce_op: add
59-
prior_args:
60-
max_z: 100
49+
save_interval: 10
50+
splits: null
51+
standardize: false
52+
test_interval: 10
53+
test_size: null
54+
train_size: 0.8
55+
trainable_rbf: false
56+
val_size: 0.05
57+
weight_decay: 0.0

examples/example.yaml renamed to examples/ET-MD17.yaml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,56 @@ activation: silu
22
aggr: add
33
atom_filter: -1
44
attn_activation: silu
5-
batch_size: 16
5+
batch_size: 8
66
coord_files: null
77
cutoff_lower: 0.0
88
cutoff_upper: 5.0
9-
dataset: QM9
10-
dataset_arg: energy_U0
11-
dataset_root: /home/philipp/Documents/data/qm9
12-
derivative: false
9+
dataset: MD17
10+
dataset_arg: aspirin
11+
dataset_root: ~/data
12+
derivative: true
1313
distance_influence: both
14-
distributed_backend: ddp_cpu
15-
early_stopping_patience: 30
14+
distributed_backend: ddp
15+
early_stopping_patience: 300
1616
ema_alpha_dy: 1.0
17-
ema_alpha_y: 1.0
17+
ema_alpha_y: 0.05
1818
embed_files: null
1919
embedding_dimension: 128
2020
energy_files: null
21-
energy_weight: 1.0
21+
energy_weight: 0.2
2222
force_files: null
23-
force_weight: 1.0
24-
inference_batch_size: 16
23+
force_weight: 0.8
24+
inference_batch_size: 64
2525
load_model: null
26-
log_dir: /tmp/logs
27-
lr: 0.0001
26+
log_dir: logs/
27+
lr: 0.001
2828
lr_factor: 0.8
29-
lr_min: 1.0e-06
30-
lr_patience: 10
31-
lr_warmup_steps: 0
29+
lr_min: 1.0e-07
30+
lr_patience: 30
31+
lr_warmup_steps: 1000
3232
max_num_neighbors: 32
3333
max_z: 100
34+
model: equivariant-transformer
3435
neighbor_embedding: true
35-
ngpus: 0
36-
num_epochs: 300
36+
ngpus: -1
37+
num_epochs: 3000
3738
num_heads: 8
3839
num_layers: 6
3940
num_nodes: 1
40-
num_rbf: 20
41-
num_workers: 4
41+
num_rbf: 32
42+
num_workers: 6
4243
output_model: Scalar
4344
precision: 32
44-
prior_model: Atomref
45+
prior_model: null
4546
rbf_type: expnorm
4647
redirect: false
4748
reduce_op: add
48-
save_interval: 3
49-
seed: 1
49+
save_interval: 10
5050
splits: null
51-
standardize: false
52-
test_interval: 3
51+
standardize: true
52+
test_interval: 10
5353
test_size: null
54-
train_size: 110000
54+
train_size: 950
5555
trainable_rbf: false
56-
val_size: 10000
56+
val_size: 50
5757
weight_decay: 0.0
Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,57 @@
1+
activation: silu
2+
aggr: add
3+
atom_filter: -1
4+
attn_activation: silu
5+
batch_size: 128
6+
coord_files: null
7+
cutoff_lower: 0.0
8+
cutoff_upper: 5.0
9+
dataset: QM9
10+
dataset_arg: energy_U0
11+
dataset_root: ~/data
12+
derivative: false
13+
distance_influence: both
14+
distributed_backend: ddp
15+
early_stopping_patience: 150
16+
ema_alpha_dy: 1.0
17+
ema_alpha_y: 1.0
18+
embed_files: null
19+
embedding_dimension: 256
20+
energy_files: null
21+
energy_weight: 1.0
22+
force_files: null
23+
force_weight: 1.0
24+
inference_batch_size: 128
125
load_model: null
2-
conf: null
3-
num_epochs: 3000
4-
batch_size: 300
5-
inference_batch_size: 300
6-
lr: 0.01
7-
lr_patience: 5
26+
log_dir: logs/
27+
lr: 0.0004
28+
lr_factor: 0.8
829
lr_min: 1.0e-07
9-
lr_factor: 0.5
30+
lr_patience: 15
1031
lr_warmup_steps: 10000
11-
early_stopping_patience: 500
12-
weight_decay: 0.0
13-
ema_alpha_y: 1.0
14-
ema_alpha_dy: 1.0
32+
max_num_neighbors: 32
33+
max_z: 100
34+
model: equivariant-transformer
35+
neighbor_embedding: true
1536
ngpus: -1
37+
num_epochs: 3000
38+
num_heads: 8
39+
num_layers: 8
1640
num_nodes: 1
17-
precision: 32
18-
log_dir: /shared/philipp/geometric/logs/transformer-ANI1/
19-
splits: null
20-
train_size: 0.8
21-
val_size: 0.05
22-
test_size: null
23-
test_interval: 10
24-
save_interval: 10
25-
seed: 10
26-
distributed_backend: ddp
41+
num_rbf: 64
2742
num_workers: 6
28-
redirect: true
29-
dataset: ANI1
30-
dataset_root: ~/data
31-
dataset_arg: null
32-
coord_files: null
33-
embed_files: null
34-
energy_files: null
35-
force_files: null
36-
energy_weight: 1.0
37-
force_weight: 1.0
38-
model: transformer
3943
output_model: Scalar
44+
precision: 32
4045
prior_model: Atomref
41-
embedding_dimension: 256
42-
num_layers: 8
43-
num_rbf: 64
44-
activation: silu
4546
rbf_type: expnorm
46-
trainable_rbf: false
47-
neighbor_embedding: true
48-
distance_influence: both
49-
attn_activation: silu
50-
num_heads: 8
51-
derivative: false
52-
cutoff_lower: 0.0
53-
cutoff_upper: 5.0
54-
atom_filter: -1
55-
max_z: 100
56-
max_num_neighbors: 32
57-
standardize: false
47+
redirect: false
5848
reduce_op: add
59-
prior_args:
60-
max_z: 100
49+
save_interval: 10
50+
splits: null
51+
standardize: false
52+
test_interval: 10
53+
test_size: null
54+
train_size: 110000
55+
trainable_rbf: false
56+
val_size: 10000
57+
weight_decay: 0.0

examples/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Examples
2+
3+
## Training
4+
We provide three example config files for the ET for training on QM9, MD17 and ANI1 respectively. To train on a QM9 target other than `energy_U0`, change the parameter `dataset_arg` in the QM9 config file. Changing the MD17 molecule to train on works analogously. To train an ET from scratch you can use the following code from the torchmd-net directory:
5+
```bash
6+
CUDA_VISIBLE_DEVICES=0,1 python scripts/train.py --conf examples/ET-{QM9,MD17,ANI1}.yaml
7+
```
8+
Use the `CUDA_VISIBLE_DEVICES` environment variable to select which and how many GPUs you want to train on. The example above selects GPUs with indices 0 and 1. The training code will want to save checkpoints and config files in a directory called `logs/`, which you can change either in the config .yaml file or as an additional command line argument: `--log-dir path/to/log-dir`.
9+
10+
## Loading checkpoints
11+
You can access several pretrained checkpoint files under the following URLs:
12+
- equivariant Transformer pretrained on QM9 (U0): http://pub.htmd.org/et-qm9.zip
13+
- equivariant Transformer pretrained on MD17 (aspirin): http://pub.htmd.org/et-md17.zip
14+
- equivariant Transformer pretrained on ANI1: http://pub.htmd.org/et-ani1.zip
15+
- invariant Transformer pretrained on ANI1: http://pub.htmd.org/t-ani1.zip
16+
17+
The checkpoints can be loaded using the `load_model` function in TorchMD-Net. Additional model arguments (e.g. turning on force prediction on top of energies) for inference can also be passed to the function. See the following example code for loading an ET pretrained on the ANI1 dataset:
18+
```python
19+
from torchmdnet.models.model import load_model
20+
model = load_model("ANI1-equivariant_transformer/epoch=209-val_loss=0.0003-test_loss=0.0093.ckpt", derivative=True)
21+
```
22+
The following example shows how to run inference on the model checkpoint. For single molecules, you just have to pass atomic numbers and position tensors, to evaluate the model on multiple molecules simultaneously, also include a batch tensor, which contains the molecule index of each atom.
23+
```python
24+
import torch
25+
26+
# single molecule
27+
z = torch.tensor([1, 1, 8], dtype=torch.long)
28+
pos = torch.rand(3, 3)
29+
energy, forces = model(z, pos)
30+
31+
# multiple molecules
32+
z = torch.tensor([1, 1, 8, 1, 1, 8], dtype=torch.long)
33+
pos = torch.rand(6, 3)
34+
batch = torch.tensor([0, 0, 0, 1, 1, 1], dtype=torch.long)
35+
energies, forces = model(z, pos, batch)
36+
```

0 commit comments

Comments
 (0)