Analogical reasoning has been a principal focus of various waves of AIresearch. Analogy is particularly challenging for machines because it requiresrelational structures to be represented such that they can be flexibly appliedacross diverse domains of experience. Here, we study how analogical reasoningcan be induced in neural networks that learn to perceive and reason about rawvisual data. We find that the critical factor for inducing such a capacity isnot an elaborate architecture, but rather, careful attention to the choice ofdata and the manner in which it is presented to the model. The most robustcapacity for analogical reasoning is induced when networks learn analogies bycontrasting abstract relational structures in their input domains, a trainingmethod that uses only the input data to force models to learn about importantabstract features. Using this technique we demonstrate capacities for complex,visual and symbolic analogy making and generalisation in even the simplestneural network architectures.