In weighted mean squares error (WMSE) function, each sample error multiplies a weighting coefficient, then it can make noise error have a smaller proportion in the cost function, even the outliers can't affect the learning of the neural networks by tuning the smooth parameter , which enhances the anti-noise ability of neural networks. If the samples don't have noise samples, weighted mean squares error function can make neural networks avoid over-fitting. When the neural networks are linear models, the new cost function turns into a realization of weighted least squares method, the simulation results show the advantages and application conditions of the weighted squares error function.