diff options
author | cph <stegben.benjamin@gmail.com> | 2017-06-21 13:34:26 +0300 |
---|---|---|
committer | Soumith Chintala <soumith@gmail.com> | 2017-06-22 20:20:07 +0300 |
commit | b41b5ffad8d68fb7f33709ce7067f159f3092dd3 (patch) | |
tree | 66eb385ff46912d69d6ff49656fe2d7918b58fa9 | |
parent | 4dec60a39d6d5cca57e5158b10ca16b184ef66bf (diff) |
add asserts to BCECriterion
-rw-r--r-- | lib/THNN/generic/BCECriterion.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/THNN/generic/BCECriterion.c b/lib/THNN/generic/BCECriterion.c index 55909ba..637a406 100644 --- a/lib/THNN/generic/BCECriterion.c +++ b/lib/THNN/generic/BCECriterion.c @@ -18,12 +18,18 @@ void THNN_(BCECriterion_updateOutput)(THNNState *state, THTensor *input, real x = *input_data; real y = *target_data; real w = *weights_data; + THAssertMsg(x >= 0. && x <= 1., + "input value should be between 0~1, but got %f", + (double) x); sum -= (log(x + EPS) * y + log(1. - x + EPS) * (1. - y)) * w; ) else TH_TENSOR_APPLY2(real, input, real, target, real x = *input_data; real y = *target_data; + THAssertMsg(x >= 0. && x <= 1., + "input value should be between 0~1, but got %f", + (double) x); sum -= log(x + EPS) * y + log(1. - x + EPS) * (1. - y); ); |