In this work, by introducing the seismic impedance tensor we propose a new Rayleigh wave dispersion function in a homogeneous and layered medium of the Earth, which provides an efficient way to compute the dispersion curve -- a relation between the frequencies and the phase velocities. With this newly established forward model, based on the Mixture Density Networks (MDN) we develop a machine learning based inversion approach, named as FW-MDN, for the problem of estimating the S-wave velocity from the dispersion curves. The method FW-MDN deals with the non-uniqueness issue encountered in studies that invert dispersion curves for crust and upper mantle models and attains a satisfactory performance on the dataset with various noise structure. Numerical simulations are performed to show that the FW-MDN possesses the characteristics of easy calculation, efficient computation, and high precision for the model characterization.