Doing pairwise distance computation with TensorFlow
<p>I'm trying to impelement this article:
<a href="http://ronan.collobert.com/pub/matos/2008_deep_icml.pdf">http://ronan.collobert.com/pub/matos/2008_deep_icml.pdf</a>
Specfically the equation (3) from section 2.</p>

<p>Shortly I want to do a pairwise distance computation for the features of each mini-batch and insert this loss to the general network loss.
I have only the Tesnor of the batch (16 samples), the labels tensor of the batch and the batch feature Tensor.</p>

<p>After looking for quite a while I still couldn't figure out the following:</p>

<p>1) How do I divide the batch for Positive (i.e. same label) and negative pairs. Since Tensor are not iterateble I can't figure out how to get which sample have which label and then divide my vector, or get which indices of the tensor belong to each class.</p>

<p>2) How can I do pairwise distance calculation for some of the indices in the batch tensor?</p>

<p>3) I also need to define a new distance function for negative examples</p>

<p>Overall, I need to get which indices belong to which class, do a positive pair-wise distace calculation for all positive pairs. And do another calculation for all negative pairs. Then sum it all up and add it to the network loss.</p>

<p>Any help (to one of more of the 3 issues) would be highly appreciated.</p>