As in previous research , backpropagation with the ADAM optimizer was used to train the RNN. The goal is to minimize a cost function 𝐽(𝑤) for all molecules in the training set. To achieve that, it calculates from the last to the first step the average of the 𝐽(𝑤) of a set of sequences (a batch). From this, a gradient is calculated which can be used to iteratively fit the model to the training data. Formally, the loss function is the partial LL up to position 𝑖: