Recent developments in the application of aperiodic fiber Bragg gratings (AFBG) in astrophotonics, such as AFBGs for astronomical near-infrared OH suppression and gas detection based on cross-correlation spectroscopy, have illuminated a new problem that the optimization for AFBG with certain fabrication constraints has not been fully investigated and solved. Previous solutions will either sacrifice part of the spectral features or consume a significant amount of computation resources and time. Inspired by recently successful applications of artificial neural networks (ANN) in photonics inverse design, we develop a novel AFBG optimization approach employing ANNs in conjunction with genetic algorithms (GA) for the first time. The new approach maintains the spectral notch depths and preserves the 4th-order super-Gaussian spectral features with improvements of interline loss by $\sim$100 times. We also implement the first inverse scattering neural network based on a tandem architecture for AFBGs, using 1st-order Gaussian notch profile. The neural network has a good predictive capability for the magnitude but not the phase part of the design. We discuss possible ways to overcome these limitations.