Implement methods for training neural network.