What losses can be used to predict a scalar value?

The Ground Truth label is [0.0,1.0]. And I want to predict this scalar value.

In this case, What losses can be used ?

Can I use MSE loss with nn.Linear(input_dim, 1)?

networks = nn.Sequential(... , nn.Linear(input_dim, 1)
predictions = networks(input)
loss = MSE(predictions, GT)

Thanks in advance !

Hello oasjd7!

If by this you mean that each individual training sample is assigned a
ground-truth target of either 0.0 or 1.0, I would call this a binary
value (although still technically a scalar).

For a binary classification problem BCEWithLogitsLoss will be your
best choice for the loss function.

You could, but general experience shows that for binary classification
MSELoss won’t work nearly as well as BCEWithLogitsLoss.

If your ground-truth target value were a (morally speaking) continuous
variable, then MSELoss would be the sensible choice.

For example, if you were training a network to predict the price of used
cars (given, say, model, miles, age, rust, etc.) and your training data
included known prices, the MSELoss would be the natural choice.

Best.

K. Frank