Attentive Recurrent ComparatorsAttentive Recurrent Comparators (2017, Pranav Shyam, Shubham Gupta, Ambedkar Dukkipati) by Pranav Shyam et al. is an interesting paper that helps to answer the question you're wondering, along with a blog post that helps to describe it in easier terms.
The way it's implemented is actually rather intuitive. If you have ever played a "what is different" game with two images usually what you'd do is look back and forth between the images to see what the difference is. The network that the researchers created does just that! It looks at one image and then remembers important features about that images and looks at the other image and goes back and forth.