@DimTrigkakis, I think another way is to make your network accept anchor, positive and negative image at once, inside
the network’s, you define a forward_once()  method to compute the image feature, in your forward() method, you run forward_once() method 3 times with anchor, positive and negative images respectively and return their features. You can also find more info here 23.