Apply AD to Neural Network Training