From 3aae78159b6b9cd12f2a60b071c7e86abf45e7ee Mon Sep 17 00:00:00 2001 From: wanghaoshuang Date: Tue, 6 Feb 2018 16:36:31 +0800 Subject: [PATCH] Change the dims of empty result to [1, 1] --- paddle/operators/ctc_align_op.cu | 2 +- paddle/operators/ctc_align_op.h | 2 +- python/paddle/v2/fluid/layers/nn.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paddle/operators/ctc_align_op.cu b/paddle/operators/ctc_align_op.cu index 918df83eff..cea595d7c5 100644 --- a/paddle/operators/ctc_align_op.cu +++ b/paddle/operators/ctc_align_op.cu @@ -82,7 +82,7 @@ class CTCAlignOpCUDAKernel : public framework::OpKernel { output->Resize({static_cast(host_out_lod0.back()), 1}); if (host_out_lod0.back() == 0) { - output->Resize({1}); + output->Resize({1, 1}); output->mutable_data(ctx.GetPlace()); math::SetConstant set_constant; set_constant(ctx.template device_context(), diff --git a/paddle/operators/ctc_align_op.h b/paddle/operators/ctc_align_op.h index 7a063870f3..54ad1d6f5c 100644 --- a/paddle/operators/ctc_align_op.h +++ b/paddle/operators/ctc_align_op.h @@ -71,7 +71,7 @@ class CTCAlignKernel : public framework::OpKernel { output->Resize({static_cast(output_lod0.back()), 1}); // for empty sequence if (output_lod0.back() == 0) { - output->Resize({1}); + output->Resize({1, 1}); output_data = output->mutable_data(ctx.GetPlace()); output_data[0] = -1; } diff --git a/python/paddle/v2/fluid/layers/nn.py b/python/paddle/v2/fluid/layers/nn.py index 2209625344..0b3b56bc22 100644 --- a/python/paddle/v2/fluid/layers/nn.py +++ b/python/paddle/v2/fluid/layers/nn.py @@ -2526,7 +2526,7 @@ def ctc_greedy_decoder(input, blank, name=None): Returns: Variable: CTC greedy decode result. If all the sequences in result were - empty, the result LoDTensor will be [-1] with LoD [[0]] and dims [1]. + empty, the result LoDTensor will be [-1] with LoD [[0]] and dims [1, 1]. Examples: .. code-block:: python -- GitLab