  In this work, we propose using the mixture density network (MDN) to estimate
cosmological parameters. We test the MDN method by constraining parameters of
the $\Lambda$CDM and $w$CDM models using Type Ia supernovae and the power
spectra of the cosmic microwave background. We find that the MDN method can
achieve the same level of accuracy as the Markov Chain Monte Carlo method, with
a slight difference of $\mathcal{O}(10^{-2}\sigma)$. Furthermore, the MDN
method can provide accurate parameter estimates with $\mathcal{O}(10^3)$
forward simulation samples, which are useful for complex and resource-consuming
cosmological models. This method can process either one data set or multiple
data sets to achieve joint constraints on parameters, extendable for any
parameter estimation of complicated models in a wider scientific field. Thus,
the MDN provides an alternative way for likelihood-free inference of
parameters.
