We introduce a novel neural network structure called strongly constrained theory-guided neural network (SCTgNN), to investigate the behaviour of the localized solutions of the generalized nonlinear Schrödinger (NLS) equation. This equation comprises four physically significant nonlinear evolution equations, namely, the NLS, Hirota, Lakshmanan–Porsezian–Daniel and fifth-order NLS equations. The generalized NLS equation demonstrates nonlinear effects up to quintic order, indicating rich and complex dynamics in various fields of physics. By combining concepts from the physics-informed neural network and theory-guided neural network (TgNN) models, the SCTgNN aims to enhance our understanding of complex phenomena, particularly within nonlinear systems that defy conventional patterns. To begin, we employ the TgNN method to predict the behaviour of localized waves, including solitons, rogue waves and breathers, within the generalized NLS equation. We then use the SCTgNN to predict the aforementioned localized solutions and calculate the mean square errors in both the SCTgNN and TgNN in predicting these three localized solutions. Our findings reveal that both models excel in understanding complex behaviour and provide predictions across a wide variety of situations.