I’m using PyTorch to build a model for binary classification.
class XceptionLike(nn.Module):
def __init__(self):
super().__init__()
# CNN part
...
# final
self.fc_last_1 = nn.Linear(384, 64)
self.fc_last_2 = nn.Linear(64, 1)
def forward(self, input_16, input_32, input_48):
# CNN part
...
out = torch.cat([out_16, out_32, out_48], dim=1)
out = F.relu(self.fc_last_1(out))
out = F.relu(self.fc_last_2(out))
return out
# the model output part
output = model(batch_z_16, batch_z_32, batch_z_48) # model prediction
output = torch.sigmoid(output)
loss = criterion(output, batch_label)
What confuses me is that can this model used for binary classification really?
In my understanding, for binary classification
-
output of model [0, 0.5] means prediction for one class.
-
output of model [0.5, 1] means prediction for the other one.
But ReLU function returns [0, positive infinity],
and when sigmoid function gets the output of the model,
it returns [0.5, 1], so the model cant’t return [0, 0.5], which means it can’t predict the class which is belong to [0, 0.5].
What is wrong with my understanding?
How can I deal with it?