Hi @karanjeswani ,
The issue you pointed to helped!
image732×389 58.1 KB
After substituting torch.clamp with nn.ReLU, the training worked fine as seen above!
# Find the triplet loss by using the two distances obtained above

# Previously in the loss function:
distances = distances.clamp(min = self.eps)
triplet_loss = (toughest_positive_distance - toughest_negative_distance + self.margin).clamp(min = self.eps)

# Currently in the loss function:
distances = nn.ReLU()(distances)
triplet_loss = nn.ReLU()(toughest_positive_distance - toughest_negative_distance + self.margin)
        

Thanks a ton!