In conventional speech enhancement methods, the target of noise mask in the time-frequency domain is based on deep neural networks (DNN), such as ideal ratio mask and phase-sensitive mask, in which they do not consider the dependency of spectrum. In this paper, an ideal real-valued ratio mask (IRVRM) extraction method is proposed based on the analysis-by-synthesis (ABS) for utilizing the dependency of spectrum. In the synthesis process, the enhanced speech is obtained by inverse short-time Fourier transform (ISTFT) of the masked spectrum, whereas in the analysis process, the IRVRM is determined by maximizing speech quality of the reconstructed speech from mask space. The ABS loop algorithm is proposed to reduce computational complexity, namely, the best mask in the specifically generated subspace is conducted in each loop. After the ABS loop, the approximated IRVRM is conducted. This IRVRM is further utilized as the training target of the DNN. The experimental results show that when the extracted IRVRM with the ABS loop is employed as the training target of the DNN, the speech quality is effectively improved in the DNN-based noise masking.