[Here's][1] an interesting paper that helps to answer the question you're wondering, along with a [blog post][2] 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.


  [1]: https://arxiv.org/pdf/1703.00767.pdf
  [2]: https://medium.com/datadriveninvestor/spot-the-difference-deep-learning-edition-f1a891342e13