From d321880ff443a86c3ab569e8add8b917d2f5e663 Mon Sep 17 00:00:00 2001 From: John Langford Date: Fri, 26 Dec 2014 11:07:54 -0500 Subject: change loss checking to loss computation --- vowpalwabbit/loss_functions.cc | 6 ++++-- vowpalwabbit/simple_label.cc | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'vowpalwabbit') diff --git a/vowpalwabbit/loss_functions.cc b/vowpalwabbit/loss_functions.cc index 0cdc5fa7..4d67ae5e 100644 --- a/vowpalwabbit/loss_functions.cc +++ b/vowpalwabbit/loss_functions.cc @@ -127,7 +127,8 @@ public: } float getLoss(shared_data*, float prediction, float label) { - assert(label == -1.f || label == 1.f); + if (label != -1.f && label != 1.f) + cout << "You are using a label not -1 or 1 with a loss function expecting that!" << endl; float e = 1 - label*prediction; return (e > 0) ? e : 0; } @@ -170,7 +171,8 @@ public: } float getLoss(shared_data*, float prediction, float label) { - assert(label == -1.f || label == 1.f || label == FLT_MAX); + if (label != -1.f && label != 1.f) + cout << "You are using a label not -1 or 1 with a loss function expecting that!" << endl; return log(1 + exp(-label * prediction)); } diff --git a/vowpalwabbit/simple_label.cc b/vowpalwabbit/simple_label.cc index 9e220cde..3bf748de 100644 --- a/vowpalwabbit/simple_label.cc +++ b/vowpalwabbit/simple_label.cc @@ -15,8 +15,6 @@ char* bufread_simple_label(shared_data* sd, label_data* ld, char* c) { ld->label = *(float *)c; c += sizeof(ld->label); - if (sd->binary_label && fabs(ld->label) != 1.f && ld->label != FLT_MAX) - cout << "You are using a label not -1 or 1 with a loss function expecting that!" << endl; ld->weight = *(float *)c; c += sizeof(ld->weight); ld->initial = *(float *)c; -- cgit v1.2.3