I want to implement single class classification(output should be just single probability number). is there any example? or guide ?
I did multi-class classification, but I couldn’t modify it to single class… (if I use single class, training always shows loss: 0)
A single-class classification wouldn’t make much sense, since your model wouldn’t learn anything and will just output a high probability for the single class.
A “perfect” classifier would thus be:
as no other class indices are valid.
Assuming you are dealing with a binary classification, you could treat it as a 2-class multi-class classification (i.e. with
nn.CrossEntropyLoss as the criterion) and use 2 output values or alternatively you could use a single output neuron and use
nn.BCEWithLogitsLoss. The lower the output value of this neuron the more likely class0, the higher the more likely class1 was detected.