7.1. Test a model#
The frozen model can be used in many ways. The most straightforward test can be performed using dp test. A typical usage of dp test is
dp test -m graph.pb -s /path/to/system -n 30
where -m gives the tested model, -s the path to the tested system and -n the number of tested frames. Several other command line options can be passed to dp test, which can be checked with
$ dp test --help
An explanation will be provided
usage: dp test [-h] [-v {DEBUG,3,INFO,2,WARNING,1,ERROR,0}] [-l LOG_PATH]
[-m MODEL]
[-s SYSTEM | -f DATAFILE | --train-data TRAIN_JSON | --valid-data VALID_JSON]
[-S SET_PREFIX] [-n NUMB_TEST] [-r RAND_SEED] [--shuffle-test]
[-d DETAIL_FILE] [-a] [--head HEAD]
options:
-h, --help show this help message and exit
-v {DEBUG,3,INFO,2,WARNING,1,ERROR,0}, --log-level {DEBUG,3,INFO,2,WARNING,1,ERROR,0}
set verbosity level by string or number, 0=ERROR, 1=WARNING, 2=INFO and 3=DEBUG (default: INFO)
-l LOG_PATH, --log-path LOG_PATH
set log file to log messages to disk, if not specified, the logs will only be output to console (default: None)
-m MODEL, --model MODEL
Frozen model file (prefix) to import. TensorFlow backend: suffix is .pb; PyTorch backend: suffix is .pth. (default: frozen_model)
-s SYSTEM, --system SYSTEM
The system dir. Recursively detect systems in this directory (default: .)
-f DATAFILE, --datafile DATAFILE
The path to the datafile, each line of which is a path to one data system. (default: None)
--train-data TRAIN_JSON
The input json file. Training data in the file will be used for testing. (default: None)
--valid-data VALID_JSON
The input json file. Validation data in the file will be used for testing. (default: None)
-S SET_PREFIX, --set-prefix SET_PREFIX
[DEPRECATED] Deprecated argument. (default: None)
-n NUMB_TEST, --numb-test NUMB_TEST
The number of data for test. 0 means all data. (default: 0)
-r RAND_SEED, --rand-seed RAND_SEED
The random seed (default: None)
--shuffle-test Shuffle test data (default: False)
-d DETAIL_FILE, --detail-file DETAIL_FILE
The prefix to files where details of energy, force and virial accuracy/accuracy per atom will be written (default: None)
-a, --atomic Test the accuracy of atomic label, i.e. energy / tensor (dipole, polar) (default: False)
--head HEAD, --model-branch HEAD
(Supported backend: PyTorch) Task head (alias: model branch) to test if in multi-task mode. (default: None)
examples:
dp test -m graph.pb -s /path/to/system -n 30
7.1.1. Evaluate descriptors#
The descriptors of a model can be evaluated and saved using dp eval-desc. A typical usage of dp eval-desc is
dp eval-desc -m graph.pb -s /path/to/system -o desc
where -m gives the model file, -s the path to the system directory (or -f for a datafile containing paths to systems), and -o the output directory where descriptor files will be saved. The descriptors for each system will be saved as .npy files with the format desc/(system_name).npy. Each descriptor file contains a 3D array with shape (nframes, natoms, ndesc).
Several other command line options can be passed to dp eval-desc, which can be checked with
$ dp eval-desc --help
An explanation will be provided
usage: dp eval-desc [-h] [-v {DEBUG,3,INFO,2,WARNING,1,ERROR,0}] [-l LOG_PATH]
[-m MODEL] [-s SYSTEM | -f DATAFILE] [-o OUTPUT]
[--head HEAD]
options:
-h, --help show this help message and exit
-v {DEBUG,3,INFO,2,WARNING,1,ERROR,0}, --log-level {DEBUG,3,INFO,2,WARNING,1,ERROR,0}
set verbosity level by string or number, 0=ERROR, 1=WARNING, 2=INFO and 3=DEBUG (default: INFO)
-l LOG_PATH, --log-path LOG_PATH
set log file to log messages to disk, if not specified, the logs will only be output to console (default: None)
-m MODEL, --model MODEL
Frozen model file (prefix) to import. TensorFlow backend: suffix is .pb; PyTorch backend: suffix is .pth. (default: frozen_model)
-s SYSTEM, --system SYSTEM
The system dir. Recursively detect systems in this directory (default: .)
-f DATAFILE, --datafile DATAFILE
The path to the datafile, each line of which is a path to one data system. (default: None)
-o OUTPUT, --output OUTPUT
Output directory for descriptor files. Descriptors will be saved as desc/(system_name).npy (default: desc)
--head HEAD, --model-branch HEAD
(Supported backend: PyTorch) Task head (alias: model branch) to use if in multi-task mode. (default: None)
examples:
dp eval-desc -m graph.pb -s /path/to/system -o desc