Would you implement validation method after threshold in this way?

I’m trying to implement this validation error on my value. So i’m having my prediction thresholding it above 0.5 to be 1 and less to 0 then I compare it with the real value to get the validation error. my question is just a matter of pytorch coding

y_pred = y_pred.gt(0.5001).float()
return (y_pred.eq(y)).float().mean() 

I used 0.5001 because with 0.5 and with the value is 0.5 it was always giving 1, it is like it is doing torch.ge
flot is just because can’t compare byte with float or even take a mean of byte