We derive the total cold gas, atomic hydrogen, and molecular gas masses of approximately 24 000 galaxies covering four decades in stellar mass at redshifts 0.5 < z < 3.0, taken from the CANDELS survey. Our inferences are based on the inversion of a molecular hydrogen based star formation law, coupled with a prescription to separate atomic and molecular gas. We find that: 1) there is an increasing trend between the inferred cold gas (H I and H 2 ), H I, and H 2 mass and the stellar mass of galaxies down to stellar masses of 10 8 M already in place at z = 3; 2) the molecular fractions of cold gas increase with increasing stellar mass and look-back time; 3) there is hardly any evolution in the mean H I content of galaxies at fixed stellar mass; 4) the cold gas fraction and relative amount of molecular hydrogen in galaxies decrease at a relatively constant rate with time, independent of stellar mass; 5) there is a large population of low-stellar mass galaxies dominated by atomic gas. These galaxies are very gas rich, but only a minor fraction of their gas is molecular; 6) the ratio between star-formation rate (SFR) and inferred total cold gas mass (H I + H 2 ) of galaxies (i.e., star-formation efficiency; SFE) increases with star-formation at fixed stellar masses. Due to its simplicity, the presented approach is valuable to assess the impact of selection biases on small samples of directly-observed gas masses and to extend scaling relations down to stellar mass ranges and redshifts that are currently difficult to probe with direct measurements of gas content.