Skip to content
Snippets Groups Projects
Commit 04780fb6 authored by Franck Dary's avatar Franck Dary
Browse files

Added L1 loss and removed mean from regression losses

parent c4908216
Branches
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ class LossFunction ...@@ -10,7 +10,7 @@ class LossFunction
private : private :
std::string name{"_undefined_loss_"}; std::string name{"_undefined_loss_"};
std::variant<torch::nn::CrossEntropyLoss, torch::nn::BCELoss, torch::nn::MSELoss, CustomHingeLoss> fct; std::variant<torch::nn::CrossEntropyLoss, torch::nn::BCELoss, torch::nn::MSELoss, CustomHingeLoss, torch::nn::L1Loss> fct;
public : public :
......
...@@ -10,7 +10,9 @@ void LossFunction::init(std::string name) ...@@ -10,7 +10,9 @@ void LossFunction::init(std::string name)
else if (util::lower(name) == "bce") else if (util::lower(name) == "bce")
fct = torch::nn::BCELoss(torch::nn::BCELossOptions().reduction(torch::kMean)); fct = torch::nn::BCELoss(torch::nn::BCELossOptions().reduction(torch::kMean));
else if (util::lower(name) == "mse") else if (util::lower(name) == "mse")
fct = torch::nn::MSELoss(torch::nn::MSELossOptions().reduction(torch::kMean)); fct = torch::nn::MSELoss(torch::nn::MSELossOptions().reduction(torch::kSum));
else if (util::lower(name) == "l1")
fct = torch::nn::L1Loss(torch::nn::L1LossOptions().reduction(torch::kSum));
else if (util::lower(name) == "hinge") else if (util::lower(name) == "hinge")
fct = CustomHingeLoss(); fct = CustomHingeLoss();
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment