Title: Optimal control neural networks for data-driven discovery of gradient flows.. Abstract: This work aims to discover nonlinear dynamical systems from only a set of time series data on solution trajectories. To tackle this problem, we propose Optimal Control Networks (OCN) to learn the unknown vector field accurately and efficiently. The OCN consists of a neural network representation of the system, coupled with an optimal control formulation. Specifically, we formulate the parameter learning problem as a data-driven optimal control problem. This allows for the use of powerful optimal control tools. We derive generalization error bounds for both the solution and the vector field, and the bounds are shown to depend on both the training error and the time gaps between neighboring data. We also provide several numerical examples to demonstrate the viability of OCN, as well as its good generalization ability.