We use machine learning to identify in color images of high-redshift galaxies an astrophysical phenomenon predicted by cosmological simulations. This phenomenon, called the blue nugget (BN) phase, is the compact star-forming phase in the central regions of many growing galaxies that follows an earlier phase of gas compaction and is followed by a central quenching phase. We train a Convolutional Neural Network (CNN) with mock observed images of simulated galaxies at three phases of evolution: pre-BN, BN and post-BN, and demonstrate that the CNN successfully retrieves the three phases in other simulated galaxies. We show that BNs are identified by the CNN within a time window of $sim0.15$ Hubble times. When the trained CNN is applied to observed galaxies from the CANDELS survey at $z=1-3$, it successfully identifies galaxies at the three phases. We find that the observed BNs are preferentially found in galaxies at a characteristic stellar mass range, $10^{9.2-10.3} M_odot$ at all redshifts. This is consistent with the characteristic galaxy mass for BNs as detected in the simulations, and is meaningful because it is revealed in the observations when the direct information concerning the total galaxy luminosity has been eliminated from the training set. This technique can be applied to the classification of other astrophysical phenomena for improved comparison of theory and observations in the era of large imaging surveys and cosmological simulations.