def test_model()

in src/similarity/siamese.py [0:0]


def test_model(model, test_dl):
    
    model.eval()
    running_loss = 0.0
    running_corrects = 0
        
    for data in test_dl:
        
        img1 = data['img1'].to(DEVICE)
        img2 = data['img2'].to(DEVICE)
        labels = data['label'].to(DEVICE).float()
            
        distance = model.forward(img1,img2)         
        loss = contrastive_loss(distance, labels)
        predictions = (torch.abs(distance - labels) < args.similarity_margin).int()
        
        running_loss += loss.item()
        running_corrects += torch.sum(predictions)
    
    test_loss = running_loss / len(test_dl.dataset)
    test_acc = running_corrects.double() / len(test_dl.dataset)
    
    logger.info('Test set: Average loss: {:.8f}\n'.format(test_loss, test_acc))
    
    return test_loss, test_acc