Siamese network and cost functions