Skip to content

Instantly share code, notes, and snippets.

@neelindresh
Created July 18, 2022 14:03
Show Gist options
  • Save neelindresh/8493888fa2fc90effcb4aa7d3812a06d to your computer and use it in GitHub Desktop.
Save neelindresh/8493888fa2fc90effcb4aa7d3812a06d to your computer and use it in GitHub Desktop.
def validate(model,testx,testy):
prediction=model(testx)
prediction=torch.where(prediction>.5,1,0)
accu=accuracy_score(prediction.detach().numpy(),test_y.unsqueeze(1).detach().numpy())
f1=f1_score(prediction.detach().numpy(),test_y.unsqueeze(1).detach().numpy())
return {"accuracy":accu,"f1":f1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment