From ab9d59c5396002a1c0695075164da5109c530150 Mon Sep 17 00:00:00 2001 From: wanghaoshuang Date: Tue, 28 Nov 2017 14:45:11 +0800 Subject: [PATCH] Fix double type error while using eigen api --- paddle/operators/nce_op.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/paddle/operators/nce_op.h b/paddle/operators/nce_op.h index c41393d2602..7a910703293 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 -- GitLab