A machine learning method for simulating compressible multi-medium flows is studied. The regression prediction of multi-medium Riemann solution is realized by using neural network. In order to make the training results more consistent with the physical flow, an additional physical constraint layer is constructed according to the discontinuity relationship of the flow field. A neural network model is established and applied to practical ghost fluid method (PGFM). Through a variety of typical one-dimensional and two-dimensional multi-medium flow problems, the surrogates trained by neural networks of different sizes are verified numerically. It is found that the results of neural network model are more consistent with the real situation after embedding physical constraints. In addition, the relatively simple neural network model can meet the computing requirements. Machine learning method has high computational accuracy and efficiency, and has potential development.