This directory contains a small ready-to-run example for dpa_adapt.
The example uses 8 pre-processed QM9 molecules to fine-tune and evaluate a
DPA-based HOMO-LUMO gap predictor.
The processed data is already included, so you can run the demo directly.
examples/dpa_adapt/
|-- data/ # ready-to-use processed data
| |-- train/ # 5 training systems in deepmd/npy format
| |-- test/ # 3 test systems in deepmd/npy format
| |-- train_labels.npy
| `-- test_labels.npy
|-- scripts/
| |-- run_evaluate_frozen_sklearn.py # frozen_sklearn demo: DPA-3.1-3M + Ridge
| |-- run_evaluate_frozen_head.py # frozen_head demo: DPA-3.1-3M fine-tuning
| `-- prepare_data.py # regenerate data/ from raw GDB9 data
`-- README.md
Two evaluation scripts are provided, demonstrating different adaptation strategies.
From this directory, run either (or both):
# frozen_sklearn strategy - extract DPA features, fit a Ridge regressor
python scripts/run_evaluate_frozen_sklearn.py
# frozen_head strategy - fine-tune the prediction head with gradient steps
python scripts/run_evaluate_frozen_head.pyIf you do not activate the virtual environment, run the same commands with the environment's Python executable, for example:
../../../.venv/Scripts/python.exe scripts/run_evaluate_frozen_head.pyUses the frozen_sklearn strategy with the Domains_Drug model branch.
DPA-3.1-3M features are extracted from the training systems and a Ridge (linear)
regressor is fitted on top. Prints MAE, RMSE, and R2 on the test set.
Uses the frozen_head strategy. A fresh prediction head is trained on top of
frozen DPA-3.1-3M features with learning_rate=1e-3, batch_size=128,
max_steps=5. Prints predictions and evaluation metrics (MAE, RMSE, R2) on the
test set.
The data/ directory already contains the processed example dataset. Each system
is stored in deepmd/npy format. The included split has 5 training systems and
3 test systems. Each set.000/ directory contains a gap.npy label file. The
label key used by the example is gap.
In normal use, you do not need to run any data preparation step.
scripts/prepare_data.py is provided only for reproducibility. It rebuilds the
included data/ directory from raw GDB9/QM9 files.
Run it only if you want to recreate the processed data:
python scripts/prepare_data.pyThe script downloads gdb9.tar.gz, extracts the raw SDF and CSV files into
raw/, converts the first 8 molecules to deepmd/npy, and writes HOMO-LUMO gap
labels as gap.npy.