I am reproducing a model in a paper, model structure in the paper:

image.png810×180 6.32 KB

There are only two classes: 0 or 1.
my target is 1, and my model’s output is: tensor([[0.4853]].
How should I compute loss?
In [118]: model
Out[118]:
ISSCNN(
  (conv1): Conv1d(4, 16, kernel_size=(9,), stride=(3,))
  (conv2): Conv1d(16, 16, kernel_size=(9,), stride=(3,))
  (dropout): Dropout(p=0.3)
  (dense): Linear(in_features=192, out_features=1, bias=True)
  (sigmoid): Sigmoid()
)

In [119]: target
Out[119]: tensor([1])

In [120]: output
Out[120]: tensor([[0.4853]], grad_fn=<SigmoidBackward>)

In [121]: loss_func
Out[121]: CrossEntropyLoss()

In [122]: loss_func(output, target)