It exists networks built to learn how to differentiate between classes even if there are looking quite the same. Usually, a triplet loss is used in those networks to learn the difference between the target, a positive sample, and a negative one.
For example, those networks are used to perform identity check with face images, the algorithm learns the differences between different people instead of recognizing people.
KeywordsHere are some keywords that are possibly relevant: discriminative function, triplet loss, siamese network, one-shot learning.
Theses papers are interesting: