The RNN weights, which we denote as ψ, are first initialized with those of a pretrained RNN ψ 0 on ChEMBL data , then optimized to generate molecules x that maximize the reward given by the scoring function s(x). At each optimization step, the scoring function evaluates a batch P composed of P generated molecules, and the resulting reward is used to tune the RNN weights ψ. More precisely, this is done through stochastic gradient descent with respect to a loss function J(P) defined as