We demonstrate that the deep learning algorithm can considerably simplify the design and characterization of high efficient self-focusing varied line-spaced gratings. Our neural network is implemented with a recovery rate of up to 94% for the transmission function parameters. With numerical simulations, and optical experiments, we show that the self-focusing varied line-spaced gratings designed in such a way are endowed with enhanced functionalities, such as the intensity of first-order diffraction peak being enhanced with around a factor of 30 compared with the incident intensity, and a high ratio (about 60) between the peak intensity of the first order and the intensity of the zero-order. Our results allow the rapid design and characterization of self-focusing varied line-spaced gratings as well as optimal microstructures for targeted far-field diffraction patterns, which are playing key roles in spectroscopy and monochromatization applications.