Text this: Training multilayer neural network based on optimal control theory for limited computational resources