Skip to content

Commit

Permalink
Tweaked loss function parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnLangford committed Dec 31, 2009
1 parent 4ab9d6a commit 1908342
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BOOST_LIBRARY = /usr/local/boost/lib
ARCH = -march=nocona

# for normal fast execution.
#FLAGS = -Wall $(ARCH) -ffast-math -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -I $(BOOST_INCLUDE) -O3
FLAGS = -Wall $(ARCH) -ffast-math -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -I $(BOOST_INCLUDE) -O3

# for parallelization
#FLAGS = -Wall $(ARCH) -ffast-math -Wno-strict-aliasing -D_FILE_OFFSET_BITS=64 -I $(BOOST_INCLUDE) -O3 -fopenmp
Expand All @@ -15,7 +15,7 @@ ARCH = -march=nocona
#FLAGS = -Wall $(ARCH) -ffast-math -D_FILE_OFFSET_BITS=64 -I $(BOOST_INCLUDE) -pg -g

# for valgrind
FLAGS = -Wall $(ARCH) -ffast-math -D_FILE_OFFSET_BITS=64 -I $(BOOST_INCLUDE) -g -O0
#FLAGS = -Wall $(ARCH) -ffast-math -D_FILE_OFFSET_BITS=64 -I $(BOOST_INCLUDE) -g -O0

BINARIES = vw

Expand Down
14 changes: 9 additions & 5 deletions loss_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ embodied in the content of this file are licensed under the BSD

#include "loss_functions.h"
#include<math.h>
#include <iostream>
using namespace std;

class squaredloss : public loss_function {
public:
Expand Down Expand Up @@ -86,15 +88,17 @@ class quantileloss : public loss_function {
};

loss_function* getLossFunction(string funcName, double function_parameter) {
if(funcName.compare("squaredloss") == 0) {
if(funcName.compare("squared") == 0) {
return new squaredloss();
} else if(funcName.compare("hingeloss") == 0) {
} else if(funcName.compare("hinge") == 0) {
return new hingeloss();
} else if(funcName.compare("logloss") == 0) {
} else if(funcName.compare("logistic") == 0) {
return new logloss();
} else if(funcName.compare("quantileloss") == 0 || funcName.compare("pinballloss") == 0) {
} else if(funcName.compare("quantile") == 0 || funcName.compare("pinball") == 0 || funcName.compare("absolute") == 0) {
return new quantileloss(function_parameter);
} else {
return NULL;
cout << "Invalid loss function name: " << funcName << " Bailing!" << endl;
exit(1);
}
cout << "end getLossFunction" << endl;
}
2 changes: 1 addition & 1 deletion parse_args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ po::variables_map parse_args(int argc, char *argv[], boost::program_options::opt
("sendto", po::value< vector<string> >(), "send example to <hosts>")
("testonly,t", "Ignore label information and just test")
("thread_bits", po::value<size_t>(&global.thread_bits)->default_value(0), "log_2 threads")
("loss_function", po::value<string>()->default_value("squaredloss"), "Specify the loss function to be used, uses squaredloss by default. Currently available ones are squaredloss, hingeloss, logloss and quantileloss.")
("loss_function", po::value<string>()->default_value("squared"), "Specify the loss function to be used, uses squared by default. Currently available ones are squared, hinge, logistic and quantile.")
("quantile_tau", po::value<double>()->default_value(0.5), "Parameter \\tau associated with Quantile loss. Defaults to 0.5")
("unique_id", po::value<size_t>(&global.unique_id)->default_value(0),"unique id used for cluster parallel")
("compressed", "use gzip format whenever appropriate. If a cache file is being created, this option creates a compressed cache file. A mixture of raw-text & compressed inputs are supported if this option is on");
Expand Down

0 comments on commit 1908342

Please sign in to comment.