Skip to content

Action: ANN

Module annfunc
Description Usage
Calculates the ANN-function. used in 0 tutorialsused in 4 eggs

Details and examples

Calculates the ANN-function.

This module implements ANN class, which is a subclass of Function class. ANN class takes multi-dimensional arrays as inputs for a fully-connected feedforward neural network with specified neural network weights and generates corresponding outputs. The ANN outputs can be used as collective variables, inputs for other collective variables, or inputs for data analysis tools.

Examples

Assume we have an ANN with numbers of nodes being [2, 3, 1], and weights connecting layer 0 and 1 are

[[1,2], [3,4], [5,6]]

weights connecting layer 1 and 2 are

[[7,8,9]]

Bias for layer 1 and 2 are [10, 11, 12] and [13], respectively.

All activation functions are Tanh.

Then if input variables are l_0_out_0, l_0_out_1, the corresponding ANN function object can be defined using following plumed script:

Click on the labels of the actions for more information on what each action computes
tested on2.11
ann: ANNCalculates the ANN-function. More details ...
ARGthe labels of the values from which the function is calculated=l_0_out_0,l_0_out_1
NUM_LAYERSnumber of layers of the neural network=3
NUM_NODESnumbers of nodes in each layer of the neural network=2,3,1
ACTIVATIONSactivation functions for the neural network=Tanh,Tanh
WEIGHTS0flattened weight arrays connecting adjacent layers, WEIGHTS0 represents flattened weight array connecting layer 0 and layer 1, WEIGHTS1 represents flattened weight array connecting layer 1 and layer 2, =1,2,3,4,5,6
WEIGHTS1flattened weight arrays connecting adjacent layers, WEIGHTS0 represents flattened weight array connecting layer 0 and layer 1, WEIGHTS1 represents flattened weight array connecting layer 1 and layer 2, =7,8,9
BIASES0bias array for each layer of the neural network, BIASES0 represents bias array for layer 1, BIASES1 represents bias array for layer 2, =10,11,12
BIASES1bias array for each layer of the neural network, BIASES0 represents bias array for layer 1, BIASES1 represents bias array for layer 2, =13
...

To access its components, we use "ann.node-0", "ann.node-1", ..., which represents the components of neural network outputs.

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
PERIODICThis keyword do not have examples compulsory none if the output of your function is periodic then you should specify the periodicity of the function
NUM_LAYERS compulsory none number of layers of the neural network
NUM_NODES compulsory none numbers of nodes in each layer of the neural network
ACTIVATIONS compulsory none activation functions for the neural network
NUMERICAL_DERIVATIVESThis keyword do not have examples optional false calculate the derivatives for these quantities numerically
WEIGHTS optional not used flattened weight arrays connecting adjacent layers, WEIGHTS0 represents flattened weight array connecting layer 0 and layer 1, WEIGHTS1 represents flattened weight array connecting layer 1 and layer 2,
BIASES optional not used bias array for each layer of the neural network, BIASES0 represents bias array for layer 1, BIASES1 represents bias array for layer 2,