The PYTORCH module is an interface between PLUMED and the PyTorch machine learning library. It implements the PYTORCH_MODEL class as subclass of Function
, which allows for loading functions defined in Pytorch and compiled with TorchScript.
This allows one to use the outputs of a neural network as collective variables, as described in [16] [17]. Furthermore, the PYTORCH_MODEL outputs can also be used as inputs for other CVs and for data analysis tools. Please cite [bonati2023unified] if you use the PLUMED-libtorch interface.
The mlcolvar
package can be used to optimize neural-networks CVs based on different criteria (dimensionality reduction, classification or slow dynamical modes). The CVs are optimized in Python and the resulting model is compiled with TorchScript, in order to allow the models to be employed without Python dependencies.
This module is not installed by default. It requires the LibTorch library to be linked, see Configuring / LibTorch on how to install it. Once LibTorch has been downloaded and the relevant environment variables are set one can configure PLUMED with the following options:
> ./configure --enable-libtorch --enable-modules=pytorch
Currently, all features of the PYTORCH module are included in a single function: PYTORCH_MODEL .