Herein, example of study of optical modes propagating through spatially periodic composites is used to demonstrate that embedding physics‐driven constraints into machine‐learning process can dramatically improve accuracy and generalizability of resulting models. Comprehensive analysis of common compromises between direct physics‐based solutions, machine‐learning training and deployment times, as well as accuracies of the resulting models is presented. The approach to physics‐informed machine learning, presented in this work, can be readily utilized in other situations mapped onto an eigenvalue problem, a known bottleneck of computational electrodynamics. Crucially, the technique provides a way to train the model on configurations with no known solutions. The approach presented in this work can be utilized for machine‐learning‐driven design, optimization, and characterization of composites with 1D and 2D structure. Physics‐informed design of machine learning can be further used to produce high‐quality models, in particular, in situations where exact solutions are scarce or are slow to come up with.