To control the position of the magnetic levitation ball more accurately, this paper proposes a deep neural network feedforward compensation controller based on an improved Adagrad optimization algorithm. The control structure of the controller consists of a deep neural network identifier, a deep neural network feedforward compensator, and a PID controller. First, the dynamic inverse model of the magnetic levitation ball is established by the deep neural network identifier which is trained online based on the improved Adagrad algorithm, and the trained network parameters are dynamically copied to the deep neural network feedforward compensator. Then, the position control of the magnetic levitation ball system is realized by the output of the feedforward compensator and the PID controller. Simulations and experiments illustrate that the accuracy of the deep network feedforward compensation control based on an improved Adagrad algorithm is higher, and its control system shows good dynamic and static performance and robustness to some extent.