I’m working on a binary task and I’m figuring out Recall, Precision, etc, as implemented by Ignite. As per documentation:
“In binary and multilabel cases, the elements of y
and y_pred
should have 0 or 1 values. Thresholding of predictions can be done as below:”
def thresholded_output_transform(output):
y_pred, y = output
y_pred = torch.round(y_pred)
return y_pred, y
Am I correct to assume that output
is what is returned by the model?
I’m using BCEWithLogitsLoss, so I have to pass logits through a sigmoid function. I have to use a sigmoid here as well, right?
def thresholded_output_transform(output):
y_pred, y = output
y_pred = torch.sigmoid(y_pred)
y_pred = torch.clamp(y_pred, 0., 1.)
y_pred = torch.round(y_pred)
return y_pred, y