Topological concepts open many new horizons for photonic devices, from integrated optics to lasers. The complexity of large scale topological devices asks for an effective solution of the inverse problem: how best to engineer the topology for a specific application? We introduce a novel machine learning approach to the topological inverse problem. We train a neural network system with the band structure of the Aubry-Andre-Harper model and then adopt the network for solving the inverse problem. Our application is able to identify the parameters of a complex topological insulator in order to obtain protected edge states at target frequencies. One challenging aspect is handling the multivalued branches of the direct problem and discarding unphysical solutions. We overcome this problem by adopting a self-consistent method to only select physically relevant solutions. We demonstrate our technique in a realistic topological laser design and by resorting to the widely available open-source TensorFlow library. Our results are general and scalable to thousands of topological components. This new inverse design technique based on machine learning potentially extends the applications of topological photonics, for example, to frequency combs, quantum sources, neuromorphic computing and metrology.