Issue
I'm making a neural network that takes in ten inputs and outputs five 0-to-1 values. It's not a classifier, it's more of a box-ticking problem so usually it's more than one output node that is 1.
I'm not sure how to represent this in pytorch since the nn.softmax() function does not take the number of inputs-outputs as parameters like nn.Linear does.
class NeuralNet(nn.Module):
def __init__(self, input_size, hidden_size, num_classes):
super(NeuralNet, self).__init__()
self.fc1 = nn.Linear(input_size, hidden_size)
self.relu = nn.ReLU()
self.fc2 = nn.Linear(hidden_size, num_classes)
def forward(self, x):
out = self.fc1(x)
out = self.relu(out)
out = self.fc2(out)
return out
Also which criteria/optimizers support multi-target output? Because CrossEntropyLoss, SGD and Adam don't
Solution
What you're describing is a binary classification output. You should use BCEWithLogitsLoss
.
Answered By - Karl
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.