12/02/2021

How to combine multiple criterions to a loss function? Multiple loss function for single model.

You can simply reference below code:


ex1)

b = nn.MSELoss()(output_x, x_labels) a = nn.CrossEntropyLoss()(output_y, y_labels) loss = a + b loss.backward()


ex2)

b = nn.MSELoss() a = nn.CrossEntropyLoss() loss_a = a(output_x, x_labels) loss_b = b(output_y, y_labels) loss = loss_a + loss_b loss.backward()


And there are many opinions in here:

https://discuss.pytorch.org/t/how-to-combine-multiple-criterions-to-a-loss-function/348/27


Thank you.

www.marearts.com

πŸ™‡πŸ»‍♂️

No comments:

Post a Comment