Upcoming large-area narrow band photometric surveys, such as Javalambre Physics of the Accelerating Universe Astrophysical Survey (J-PAS), will enable us to observe a large number of galaxies simultaneously and efficiently. However, it will be challenging to analyse the spatially resolved stellar populations of galaxies from such big data to investigate galaxy formation and evolutionary history. We have applied a convolutional neural network (CNN) technique, which is known to be computationally inexpensive once it is trained, to retrieve the metallicity and age from J-PAS-like narrow-band images. The CNN was trained using synthetic photometry from the integral field unit spectra of the Calar Alto Legacy Integral Field Area survey and the age and metallicity obtained in a full spectral fitting on the same spectra. We demonstrate that our CNN model can consistently recover age and metallicity from each J-PAS-like spectral energy distribution. The radial gradients of the age and metallicity for galaxies are also recovered accurately, irrespective of their morphology. However, it is demonstrated that the diversity of the data set used to train the neural networks has a dramatic effect on the recovery of galactic stellar population parameters. Hence, future applications of CNNs to constrain stellar populations will rely on the availability of quality spectroscopic data from samples covering a wide range of population parameters.