变长序列可以用flatten压扁成一维tensor么?
Created by: hyo009
paddle版本: fluid 1.4 latest 环境:centos 6u3
模型从keras转fluid后预测:
报错信息如下:
Traceback (most recent call last): File "keras_2_fluid_all_part_map_diff_direction2_fix_multi_sum_output2.py", line 433, in <module> fetch_list=[final_output1, final_output2],return_numpy=False) File "/home/map01/.jumbo/lib/python2.7/site-packages/paddle/fluid/executor.py", line 565, in run use_program_cache=use_program_cache) File "/home/map01/.jumbo/lib/python2.7/site-packages/paddle/fluid/executor.py", line 642, in _run exe.run(program.desc, scope, 0, True, True, fetch_var_name) paddle.fluid.core.EnforceNotMet: Invoke operator concat error. Python Callstacks: File "/home/map01/.jumbo/lib/python2.7/site-packages/paddle/fluid/framework.py", line 1659, in append_op attrs=kwargs.get("attrs", None)) File "/home/map01/.jumbo/lib/python2.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op return self.main_program.current_block().append_op(*args, **kwargs) File "/home/map01/.jumbo/lib/python2.7/site-packages/paddle/fluid/layers/tensor.py", line 199, in concat attrs={'axis': axis}) File "keras_2_fluid_all_part_map_diff_direction2_fix_multi_sum_output2.py", line 133, in <module> concat2 = fluid.layers.concat([flatten1,MEAN_sum,MEDIAN_sum],axis=1,name='concat2') C++ Callstacks: Enforce failed. Expected out_dims[j] == ins[i][j], but received out_dims[j]:2 != ins[i][j]:1. Input tensors should have the same elements except the specify axis. at [/paddle/paddle/fluid/operators/concat_op.cc:66] PaddlePaddle Call Stacks: 0 0x7f054815a5a5p void paddle::platform::EnforceNotMet::Init<std::string>(std::string, char const*, int) + 357 1 0x7f054815a902p paddle::platform::EnforceNotMet::EnforceNotMet(std::string const&, char const*, int) + 82 2 0x7f0548492436p paddle::operators::ConcatOp::InferShape(paddle::framework::InferShapeContext*) const + 1526 3 0x7f0549297412p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&, paddle::framework::RuntimeContext*) const + 306 4 0x7f0549297ab3p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const + 563 5 0x7f0549295ac0p paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 240 6 0x7f05482b283ep paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) + 142 7 0x7f05482b56f4p paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::vector<std::string, std::allocator<std::string> > const&, bool) + 132 8 0x7f054814c1b4p 9 0x7f05481895fcp 10 0x7f057945a3e4p PyEval_EvalFrameEx + 25956 11 0x7f057945b130p PyEval_EvalCodeEx + 2240 12 0x7f05794594a1p PyEval_EvalFrameEx + 22049 13 0x7f057945b130p PyEval_EvalCodeEx + 2240 14 0x7f05794594a1p PyEval_EvalFrameEx + 22049 15 0x7f057945b130p PyEval_EvalCodeEx + 2240 16 0x7f057945b242p PyEval_EvalCode + 50 17 0x7f057947562cp 18 0x7f0579475700p PyRun_FileExFlags + 144 19 0x7f0579476c0cp PyRun_SimpleFileExFlags + 220 20 0x7f05794884ccp Py_Main + 3164 21 0x318ae1ecddp __libc_start_main + 253 22 0x400659p
fluid部分相关模型结构: ` MEAN_sum = fluid.layers.data(name='mean_sum', shape=[1], dtype='float32') MEDIAN_sum = fluid.layers.data(name='median_sum', shape=[1], dtype='float32')
fc1 = fluid.layers.fc(name='relu_fc1',input=attention_output,size=30,act='relu',bias_attr=True) flatten1 = fluid.layers.flatten(x=fc1, axis=1, name='flatten1') concat2 = fluid.layers.concat([flatten1,MEAN_sum,MEDIAN_sum],axis=1,name='concat2') fc2 = fluid.layers.fc(name='relu_fc2',input=concat2,size=10,act='relu',bias_attr=True) print "fc2: ",fc2 final_output2 = fluid.layers.fc(name='final_output2',input=fc2, size=1,act=None,bias_attr=True)`
其中attention_output是变长序列,flatten1应该是压扁后的一维tensor,不知这样使用是否正确?