  We present a scheme based on artificial neural networks (ANN) to estimate the
line-of-sight velocities of individual galaxies from an observed redshift-space
galaxy distribution. We find an estimate of the peculiar velocity at a galaxy
based on galaxy counts and barycenters in shells around it. By training the
network with environmental characteristics, such as the total mass and mass
center within each shell surrounding every galaxy in redshift space, our ANN
model can accurately predict the line-of-sight velocity of each individual
galaxy. When this velocity is used to eliminate the RSD effect, the two-point
correlation function (TPCF) in real space can be recovered with an accuracy
better than 1% at $s$ > 8 $h^{-1}\mathrm{Mpc}$, and 4% on all scales compared
to ground truth. The real-space power spectrum can be recovered within 3% on
$k$< 0.5 $\mathrm{Mpc}^{-1}h$, and less than 5% for all $k$ modes. The
quadrupole moment of the TPCF or power spectrum is almost zero down to $s$ = 10
$h^{-1}\mathrm{Mpc}$ or all $k$ modes, indicating an effective correction of
the spatial anisotropy caused by the RSD effect. We demonstrate that on large
scales, without additional training with new data, our network is adaptable to
different galaxy formation models, different cosmological models, and mock
galaxy samples at high redshifts and high biases, achieving less than 10% error
for scales greater than 15 $h^{-1}\mathrm{Mpc}$. As it is sensitive to
large-scale densities, it does not manage to remove Fingers of God in large
clusters, but works remarkably well at recovering real-space galaxy positions
elsewhere. Our scheme provides a novel way to predict the peculiar velocity of
individual galaxies, to eliminate the RSD effect directly in future large
galaxy surveys, and to reconstruct the 3-D cosmic velocity field accurately.
