Hi, I’m building pytorh binary classification model(eg : cat vs dog)
My model’s output is
[[0.4820, 0.5180]] and my lable is [1,0] for example.
my loss is criterion = nn.CrossEntropyLoss()
loss = criterion(outputs, true_value)
#loss = criterion([[0.4820, 0.5180]] , [1,0])

I’m expecting that, the lable is [1,0] than… output shold be [[0.99, 0.01]] like that…
BUT, there is many error or no loss is downgoing…
The datashape of lable and output is not right? please help!!
could you give me the correct shape of lable and outputs?
my shape of outputs is 1x2 and my label’s shape is 2 and batchsize is 1 in my code.
(I want to find pytorch binary classification guide at homepage but I failed T.T)
log:
I got this error.

    loss = criterion(outputs, true_value)
  File "/home/hsm/anaconda3/envs/reproducibleresearch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hsm/anaconda3/envs/reproducibleresearch/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 1048, in forward
    ignore_index=self.ignore_index, reduction=self.reduction)
  File "/home/hsm/anaconda3/envs/reproducibleresearch/lib/python3.6/site-packages/torch/nn/functional.py", line 2690, in cross_entropy
    return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
  File "/home/hsm/anaconda3/envs/reproducibleresearch/lib/python3.6/site-packages/torch/nn/functional.py", line 2382, in nll_loss
    "Expected input batch_size ({}) to match target batch_size ({}).".format(input.size(0), target.size(0))
ValueError: Expected input batch_size (1) to match target batch_size (2).