Action: PYTORCH_MODEL
| Module | pytorch |
|---|---|
| Description | Usage |
| Load a PyTorch model compiled with TorchScript. |
Details and examples
Load a PyTorch model compiled with TorchScript.
This can be a function defined in Python or a more complex model, such as a neural network optimized on a set of data. In both cases the derivatives of the outputs with respect to the inputs are computed using the automatic differentiation (autograd) feature of Pytorch.
By default it is assumed that the model is saved as: model.ptc, unless otherwise indicated by the FILE keyword. The function automatically checks for the number of output dimensions and creates a component for each of them. The outputs are called node-i with i between 0 and N-1 for N outputs.
Note that this function requires an installation of the LibTorch C++ library. Check the instructions on the module page for instructions on how to enable the module.
Examples
Load a model called torch_model.ptc that takes as input two dihedral angles and returns two outputs.
phi: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=5,7,9,15 psi: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=7,9,15,17 model: PYTORCH_MODELLoad a PyTorch model compiled with TorchScript. More details ... FILEFilename of the PyTorch compiled model=regtest/pytorch/rt-pytorch_model_2d/torch_model.ptc ARGthe labels of the values from which the function is calculated=phi,psi ... PRINTPrint quantities to a file. More details FILEthe name of the file on which to output these quantities=COLVAR ARGthe labels of the values that you would like to print to the file=model.node-0,model.node-1
Input
The arguments that serve as the input for this action are specified using one or more of the keywords in the following table.
| Keyword | Type | Description |
|---|---|---|
| ARG | scalar | the labels of the values from which the function is calculated |
Full list of keywords
The following table describes the keywords and options that can be used with this action
| Keyword | Type | Default | Description |
|---|---|---|---|
| ARG | input | none | the labels of the values from which the function is calculated |
| NUMERICAL_DERIVATIVESThis keyword do not have examples | optional | false | calculate the derivatives for these quantities numerically |
| FILE | optional | not used | Filename of the PyTorch compiled model |