Many wavefront sensors, including the Pyramid, Zernike and focal plane, have a nonlinear response for large phase aberrations. In this talk I will demonstrate techniques to mitigate these nonlinearities using machine learning. First, I will show how Neural Networks can be used as nonlinear mappings between wavefront sensor measurement and wavefront, and can lead to significantly increased dynamic range. Next, I will demonstrate how Reinforcement Learning can help us find predictive controllers that can deal with nonlinear dynamics/wavefront sensors. Finally, I will show that gradient-based optimization, which is commonly used in machine learning, can also be used to optimize the free design parameters of a wavefront sensor, leading to designs with sensitivity close to the theoretical limit.