From 5e151b2c83f70900a47431d27aa33687b407ddd4 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Wed, 2 May 2018 17:47:11 +0800 Subject: [PATCH] Follow comment --- paddle/fluid/operators/cross_entropy_op.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/operators/cross_entropy_op.h b/paddle/fluid/operators/cross_entropy_op.h index 822a83712d..19a2aec92b 100644 --- a/paddle/fluid/operators/cross_entropy_op.h +++ b/paddle/fluid/operators/cross_entropy_op.h @@ -72,13 +72,13 @@ class XeGradFunctor { size_t num_classes) : dx_(dx), dy_(dy), x_(x), label_(label), num_classes_(num_classes) {} - HOSTDEVICE void operator()(size_t label_id) { - auto x_is_true_offset = label_id * num_classes_ + label_[label_id]; - for (size_t x_offset = label_id * num_classes_; - x_offset < (label_id + 1) * num_classes_; ++x_offset) { + HOSTDEVICE void operator()(size_t sample_id) { + auto x_is_true_offset = sample_id * num_classes_ + label_[sample_id]; + for (size_t x_offset = sample_id * num_classes_; + x_offset < (sample_id + 1) * num_classes_; ++x_offset) { dx_[x_offset] = x_offset != x_is_true_offset ? static_cast(0) - : -dy_[label_id] / x_[x_offset]; + : -dy_[sample_id] / x_[x_offset]; } } -- GitLab