The neural network (NN) is extensively used for error predication and compensation in CNC machining. However, the training samples are finite and have some noises which limit the training accuracy of the neural network. Furthermore, the weight matrixes and the valve values of the NN are fixed which limit the generalization performance of the trained NN. To solve the problems, some optimization techniques are proposed in this paper. A standardized formula is proposed to standardize the training samples. The data filter is designed to eliminate the noise. A correction strategy is proposed to realize the generalization performance of the trained NN.