There is a nonlinear relationship between the velocities of Rayleigh and the compactness of soil in Rayleigh wave exploration. So, nonlinear inverse method is employed to obtain the compactness date based on the Rayleigh velocities. An artificial neural network is adapted to inverse the compactness instead of the regression analysis method. According to the comparison between the artificial neural network results and the result of impregnation sand method's at the same condition, the mean absolute error is 1. 188 6%, and the average relative error is 1. 221 4%. It illustrates that the artificial neural network method is feasible in compactness reversion, and its precision is higher than the regression analysis method.