From b8ff0972b63238dbc0fb853615967f8e339a30b7 Mon Sep 17 00:00:00 2001 From: JiabinYang Date: Mon, 12 Nov 2018 12:05:31 +0000 Subject: [PATCH] test=develop --- paddle/fluid/operators/hierarchical_sigmoid_op.h | 8 -------- python/paddle/fluid/tests/unittests/test_hsigmoid_op.py | 2 -- 2 files changed, 10 deletions(-) diff --git a/paddle/fluid/operators/hierarchical_sigmoid_op.h b/paddle/fluid/operators/hierarchical_sigmoid_op.h index 90bdb47311f..df4f5f561a2 100644 --- a/paddle/fluid/operators/hierarchical_sigmoid_op.h +++ b/paddle/fluid/operators/hierarchical_sigmoid_op.h @@ -86,7 +86,6 @@ class HierarchicalSigmoidOpKernel : public framework::OpKernel { trans(ctx.template device_context(), pre_out_data, pre_out_data + pre_out->numel(), pre_out_data, ClipFunctor(static_cast(-40.0), static_cast(40.0))); - pre_out_mat = -1 * pre_out_mat; bit_code->Sum(*pre_out, out, static_cast(-1)); // use softrelu to calculate cross entropy pre_out_mat.device(place) = (static_cast(1.0) + pre_out_mat.exp()).log(); @@ -162,16 +161,9 @@ class HierarchicalSigmoidGradOpKernel : public framework::OpKernel { bias_grad->mutable_data(ctx.GetPlace()); zero(dev_ctx, bias_grad, static_cast(0.0)); bit_code->AddGrad(pre_out_grad, bias_grad); - auto bias_grad_mat = EigenMatrix::From(*bias_grad); - bias_grad_mat = -1 * bias_grad_mat; } bit_code->MulGradWeight(pre_out_grad, w_grad, *in); bit_code->MulGradError(pre_out_grad, *w, in_grad); - auto w_grad_mat = EigenMatrix::From(*w_grad); - auto in_grad_mat = EigenMatrix::From(*in_grad); - - w_grad_mat = -1 * w_grad_mat; - in_grad_mat = -1 * in_grad_mat; } }; diff --git a/python/paddle/fluid/tests/unittests/test_hsigmoid_op.py b/python/paddle/fluid/tests/unittests/test_hsigmoid_op.py index 0a16f5a39c5..6152b96912d 100644 --- a/python/paddle/fluid/tests/unittests/test_hsigmoid_op.py +++ b/python/paddle/fluid/tests/unittests/test_hsigmoid_op.py @@ -88,7 +88,6 @@ def hsigmoid(x, w, label, bias, num_classes): # clip[-40.0, 40.0] pre_output = np.clip(pre_output, -40.0, 40.0) # out(i, 0) = \sum_j bit(i, j) * preout(i, j) - pre_output = -1 * pre_output for i in range(batch_size): code_table = CodeTable(num_classes, label[i]) length = code_table.get_length() @@ -126,7 +125,6 @@ def hsigmoidWithCustomTree(x, w, ptable, pcode, label, bias, num_classes): pre_output[i][j] += np.dot(w[idx], x[i]) # clip[-40.0, 40.0] pre_output = np.clip(pre_output, -40.0, 40.0) - pre_output = -1 * pre_output # out(i, 0) = \sum_j bit(i, j) * preout(i, j) for i in range(batch_size): code_table = CodeTableWithCustomTree(ptable, pcode, i) -- GitLab