Subject to the lack of detailed environmental information, the classical matched-field processing (MFP) may not be adapted to the accurate localization of ocean acoustic sources. In this paper, a framework that applies deep learning techniques instead of the conventional MFP method is presented for the localization of ship acoustic sources in a shallow water environment. The original data in terms of sound pressure is recorded from a vertical array placed in the costal waters. The acquired data is converted into normalized sample covariance matrices (SCMs), which are used as input data fed into the deep-learning architecture. In particular, a framework is proposed to predict the range information of a target ship in a transfer learning manner based on the pre-trained Xception model that is the state-of-the-art convolutional neural networks. The proposed method achieves a performance up to 10 km at range prediction, which is significantly better than that of conventional MFP method and some other shallow machine learning methods. Different from the MFP approach, machine-learning methods are driven directly by the data, which offers an opportunity to enable them to overcome the environmental mismatch problem.