diff --git a/paddle/operators/nce_op.h b/paddle/operators/nce_op.h index c41393d26023fc0cff75cfc9b851f35f55ff9403..7a910703293a63decf5b7f42bae20e568d713381 100644 --- a/paddle/operators/nce_op.h +++ b/paddle/operators/nce_op.h @@ -22,7 +22,7 @@ namespace paddle { namespace operators { -using framework::Tensor; +using Tensor = framework::Tensor; template @@ -107,12 +107,11 @@ class NCEKernel : public framework::OpKernel { auto input_mat = EigenMatrix::From(*(context.Input("Input"))); auto weight_mat = EigenMatrix::From(*(context.Input("Weight"))); for (size_t i = 0; i < sample_labels->numel(); ++i) { - Eigen::Tensor result = + Eigen::Tensor result = (input_mat.chip((int)(i / sample_labels->dims()[1]), 0) * weight_mat.chip(sample_labels_data[i], 0)) .sum(); sample_out_data[i] += result(0); - // activation_->forward sample_out_data[i] = (1. / (1. + exp(-sample_out_data[i]))); } // forward cost