@melgor You have an example of Triplet loss here

  
      github.com
  
  
    edgarriba/examples/blob/master/triplet/main.py#L207-L221 1.8k

"""
def __init__(self):
    super(TNet, self).__init__()
    self.features = nn.Sequential(
        nn.Conv2d(1, 32, kernel_size=7),
        nn.Tanh(),
        nn.MaxPool2d(kernel_size=2, stride=2),
        nn.Conv2d(32, 64, kernel_size=6),
        nn.Tanh()
    )
    self.classifier = nn.Sequential(
        nn.Linear(64 * 8 * 8, 128),
        nn.Tanh()
    )





  
  
    
    
  
  


I hope in some days I’ll PR it to the main repository.
Until now still testing and tuning parameters since I’m not getting the same performance as in LuaTorch.