ABSTRACT We present the novel wide and deep neural network GalaxyNet, which connects the properties of galaxies and dark matter haloes and is directly trained on observed galaxy statistics using reinforcement learning. The most important halo properties to predict stellar mass and star formation rate (SFR) are halo mass, growth rate, and scale factor at the time the mass peaks, which results from a feature importance analysis with random forests. We train different models with supervised learning to find the optimal network architecture. GalaxyNet is then trained with a reinforcement learning approach: for a fixed set of weights and biases, we compute the galaxy properties for all haloes and then derive mock statistics (stellar mass functions, cosmic and specific SFRs, quenched fractions, and clustering). Comparing these statistics to observations we get the model loss, which is minimized with particle swarm optimization. GalaxyNet reproduces the observed data very accurately and predicts a stellar-to-halo mass relation with a lower normalization and shallower low-mass slope at high redshift than empirical models. We find that at low mass, the galaxies with the highest SFRs are satellites, although most satellites are quenched. The normalization of the instantaneous conversion efficiency increases with redshift, but stays constant above z ≳ 0.5. Finally, we use GalaxyNet to populate a cosmic volume of (5.9 Gpc)3 with galaxies and predict the BAO signal, the bias, and the clustering of active and passive galaxies up to z = 4, which can be tested with next-generation surveys, such as LSST and Euclid.