Skip to content
Discussion options

You must be logged in to vote

This is the solution

def test_step(self,batch,batch_idx):
        image,label=batch
        pred = self(image)
        
        return {'label':label,'pred':pred}

def test_epoch_end(self, outputs):

    label=torch.cat([x["label"] for x in outputs])
    pred=torch.cat([x["pred"] for x in outputs])
    acc=self.metrics(pred.flatten(),label)
    pred=pred.detach().cpu().numpy().ravel()
    label=label.detach().cpu().numpy().ravel()
    
    pred=np.where(pred>0.5,1,0).astype(int)
    print('torch acc',acc)
    print(classification_report(label,pred))
    print('sklearn',accuracy_score(label,pred))


Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by akihironitta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment