Earthquake data are one of the key means by which to explore our planet. At a large scale, the layered structure of the Earth is revealed by the seismic waves of natural earthquakes that go deep into its inner core. At a local scale, seismology for exploration has successfully been employed to discover massive fossil energies. As the volume of recorded seismic data becomes greater, intelligent methods for processing such a volume of data are eagerly anticipated. In particular, earthquake focal mechanisms are important for assessing the severity of tsunamis, characterizing seismogenic faults, and investigating the stress perturbations that follow a major earthquake. Here, we report a novel deep reinforcement learning method for inverting the earthquake focal mechanism. Unlike more typical deep learning applications, which require a large training dataset, a deep reinforcement learning system learns by itself. We demonstrate the validity and efficacy of the proposed deep reinforcement learning method by applying it to the Mw 7.1 mainshock of the Ridgecrest earthquakes in southern California. In the foreseeable future, deep learning technologies may greatly contribute to our understanding of the oceanographic process. The proposed method may help us understand the mechanism of marine earthquakes.