We present a scheme based on artificial neural networks (ANNs) 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 barycentres in shells around it. By training the network with environmental characteristics, such as the total mass and mass centre 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 perâcent at s > 8 $\, h^{-1}\, \mathrm{Mpc}$, and 4 perâcent on all scales compared to ground truth. The real-space power spectrum can be recovered within 3 perâcent on k< 0.5 $\, \mathrm{Mpc}^{-1}\, h$, and less than 5 perâcent 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 perâcent 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 three-dimensional cosmic velocity field accurately.