Training an artificial neural network