Skip to content

Commit b8ff097

Browse files
committed
test=develop
1 parent 32e05b0 commit b8ff097

File tree

2 files changed

+0
-10
lines changed

2 files changed

+0
-10
lines changed

paddle/fluid/operators/hierarchical_sigmoid_op.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class HierarchicalSigmoidOpKernel : public framework::OpKernel<T> {
8686
trans(ctx.template device_context<DeviceContext>(), pre_out_data,
8787
pre_out_data + pre_out->numel(), pre_out_data,
8888
ClipFunctor<T>(static_cast<T>(-40.0), static_cast<T>(40.0)));
89-
pre_out_mat = -1 * pre_out_mat;
9089
bit_code->Sum(*pre_out, out, static_cast<T>(-1));
9190
// use softrelu to calculate cross entropy
9291
pre_out_mat.device(place) = (static_cast<T>(1.0) + pre_out_mat.exp()).log();
@@ -162,16 +161,9 @@ class HierarchicalSigmoidGradOpKernel : public framework::OpKernel<T> {
162161
bias_grad->mutable_data<T>(ctx.GetPlace());
163162
zero(dev_ctx, bias_grad, static_cast<T>(0.0));
164163
bit_code->AddGrad(pre_out_grad, bias_grad);
165-
auto bias_grad_mat = EigenMatrix<T>::From(*bias_grad);
166-
bias_grad_mat = -1 * bias_grad_mat;
167164
}
168165
bit_code->MulGradWeight(pre_out_grad, w_grad, *in);
169166
bit_code->MulGradError(pre_out_grad, *w, in_grad);
170-
auto w_grad_mat = EigenMatrix<T>::From(*w_grad);
171-
auto in_grad_mat = EigenMatrix<T>::From(*in_grad);
172-
173-
w_grad_mat = -1 * w_grad_mat;
174-
in_grad_mat = -1 * in_grad_mat;
175167
}
176168
};
177169

python/paddle/fluid/tests/unittests/test_hsigmoid_op.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def hsigmoid(x, w, label, bias, num_classes):
8888
# clip[-40.0, 40.0]
8989
pre_output = np.clip(pre_output, -40.0, 40.0)
9090
# out(i, 0) = \sum_j bit(i, j) * preout(i, j)
91-
pre_output = -1 * pre_output
9291
for i in range(batch_size):
9392
code_table = CodeTable(num_classes, label[i])
9493
length = code_table.get_length()
@@ -126,7 +125,6 @@ def hsigmoidWithCustomTree(x, w, ptable, pcode, label, bias, num_classes):
126125
pre_output[i][j] += np.dot(w[idx], x[i])
127126
# clip[-40.0, 40.0]
128127
pre_output = np.clip(pre_output, -40.0, 40.0)
129-
pre_output = -1 * pre_output
130128
# out(i, 0) = \sum_j bit(i, j) * preout(i, j)
131129
for i in range(batch_size):
132130
code_table = CodeTableWithCustomTree(ptable, pcode, i)

0 commit comments

Comments
 (0)