Multiscale computation on feedforward neural network and recurrent neural network