Intensity inhomogeneity in magnetic resonance (MR) images can decrease the performance of image processing, such as segmentation and registration. In this work, we propose an unsupervised learning approach to correct the inhomogeneity of an MR image based on deep image priors (DIPs). In DIPs, the structure of the convolutional neural networks was previously shown to capture the prior probability of an image, which has been demonstrated in several applications such as image denoising, segmentation, and super resolution. To obtain an inhomogeneity-free MR image, the problem was formulated in a Bayesian inference framework. The priors of the image and inhomogeneity field were captured by two DIPs and their likelihood was modeled based on the observed image. The approximated expectation of the posterior was calculated to get the corrected image using a stochastic gradient Langevin dynamics algorithm. Since we modeled the noise distribution, the proposed method is simultaneously capable of denoising to some extent. We compared our method with N4, a popular inhomogeneity correction method, in a simulated data set and a couple of real data sets, statistically showing that it has comparable or even superior performance than N4 when the inhomogeneity is severe or noise is high.