Can we apply both MSELoss and CrossEntropyLoss in a single network to predict both classification and regression in Deep Learning? Suppose that we have 4 points(regression) and 5 classes(classification) to predict and we use both those loss function. I have built a simple network, but I did not get a good result. I applied loss function like this:
criterion1 = nn.MSELoss()
criterion2 = nn.CrossEntropyLoss()
loss1 = criterion1(logits[:,:4], y)# regression
loss2 = criterion2(logits[:,4:].softmax(dim=1), cl) #classification
loss = .1*loss1 + loss2
loss2.backward()
optim.step()
Also I just applied only the CrossEntropyLoss to network but I got good result. So, should we use separate models to predict targets?