The hysteresis nonlinear characteristic of the nanometer positioning system based on piezoceramic actuator decreases the accuracy of the nanometer positioning stage seriously. To compensate the hysteresis nonlinearity and improve the precision of system with hysteresis, the modeling of hysteresis and the corresponding inverse compensation is studied in this paper. First, the dynamic Preisach model for hysteresis is built. Based on the original commom dynamic Preisach model, the information of historical input voltage is introduced into the Preisach function. Then a neural network is used for identification of the model. Secondly, a dynamic inverse Preisach model of hysteresis is built by introducing information of historical displacement to Preisach function and is identified using a neural network. Finally, the dynamic inverse Preisach model based on neural networks is used to compensate the hysteresis nonlinearity. The model is shown through experiments to offer high accuracy under voltage excitations with different frequency. Through the experimental results, the maximum of the absolute error predicted by the new model and inverse model is reduced to 0.1 mu m and 1V. The nonlinear characteristic is reduced effectively by the inverse compensation with neural networks, with the error below 0.7 mu m.