  The cosmic 21-cm line of hydrogen is expected to be measured in detail by the
next generation of radio telescopes. The enormous dataset from future 21-cm
surveys will revolutionize our understanding of early cosmic times. We present
a machine learning approach based on an Artificial Neural Network that uses
emulation in order to uncover the astrophysics in the epoch of reionization and
cosmic dawn. Using a seven-parameter astrophysical model that covers a very
wide range of possible 21-cm signals, over the redshift range 6 to 30 and
wavenumber range $0.05$ to $1 \ \rm{Mpc}^{-1}$ we emulate the 21-cm power
spectrum with a typical accuracy of $10 - 20\%$. As a realistic example, we
train an emulator using the power spectrum with an optimistic noise model of
the Square Kilometre Array (SKA). Fitting to mock SKA data results in a typical
measurement accuracy of $2.8\%$ in the optical depth to the cosmic microwave
background, $34\%$ in the star-formation efficiency of galactic halos, and a
factor of 9.6 in the X-ray efficiency of galactic halos. Also, with our
modeling we reconstruct the true 21-cm power spectrum from the mock SKA data
with a typical accuracy of $15 - 30\%$. In addition to standard astrophysical
models, we consider two exotic possibilities of strong excess radio backgrounds
at high redshifts. We use a neural network to identify the type of radio
background present in the 21-cm power spectrum, with an accuracy of $87\%$ for
mock SKA data.
