C预测程序中,如何跳过部分底层网络,将中间层作为输入?
Created by: fty8788
背景: DSSM模型中,一个输入是query,另一个输入是候选词。为了优化线上计算性能,候选词可以离线计算出来,在线计算只计算query部分的网络,在线和离线结果直接给softmax层
做法:
- 离线导出候选词最高隐层的输出结果
- 在线计算,修改
trainer_config.py
,删除target部分的网络,输入设为dense_vector_sequence类型 - main.c中,将离线结果生成ivector,输入给模型计算预测结果
问题: 加载原模型后,运行出core:
F0906 16:00:37.229890 28618 Parameter.cpp:349] Check failed: header.size == getSize() (32768 vs. 3455094) The size (32768) in the file does not match the size (3455094) of the parameter: ___fc_layer_1__.w0
*** Check failure stack trace: ***
@ 0x7ffff6cee87d google::LogMessage::Fail()
@ 0x7ffff6cf232c google::LogMessage::SendToLog()
@ 0x7ffff6cee3a3 google::LogMessage::Flush()
@ 0x7ffff6cf383e google::LogMessageFatal::~LogMessageFatal()
@ 0x7ffff6c6ea0a paddle::Parameter::load()
@ 0x7ffff6c6f0c7 paddle::Parameter::load()
@ 0x7ffff6b610f6 paddle::GradientMachine::loadParameters()
@ 0x7ffff6a1c433 paddle_gradient_machine_load_parameter_from_disk
@ 0x401557 main
@ 0x7ffff6483bd5 __libc_start_main
@ 0x401259 (unknown)
@ (nil) (unknown)
Program received signal SIGABRT, Aborted.
0x00007ffff64973f7 in raise () from /opt/compiler/gcc-4.8.2/lib/libc.so.6
(gdb) bt
#0 0x00007ffff64973f7 in raise () from /opt/compiler/gcc-4.8.2/lib/libc.so.6
#1 0x00007ffff64987d8 in abort () from /opt/compiler/gcc-4.8.2/lib/libc.so.6
#2 0x00007ffff6cf7715 in google::DumpStackTraceAndExit() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#3 0x00007ffff6cee87d in google::LogMessage::Fail() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#4 0x00007ffff6cf232c in google::LogMessage::SendToLog() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#5 0x00007ffff6cee3a3 in google::LogMessage::Flush() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#6 0x00007ffff6cf383e in google::LogMessageFatal::~LogMessageFatal() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#7 0x00007ffff6c6ea0a in paddle::Parameter::load(std::basic_istream<char, std::char_traits<char> >&) () at /home/yuyang/BuildAgent3/work/d55918cf60d51073/paddle/parameter/Parameter.cpp:400
#8 0x00007ffff6c6f0c7 in paddle::Parameter::load(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () at /home/yuyang/BuildAgent3/work/d55918cf60d51073/paddle/parameter/Parameter.cpp:339
#9 0x00007ffff6b610f6 in paddle::GradientMachine::loadParameters(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () at /home/yuyang/BuildAgent3/work/d55918cf60d51073/paddle/gserver/gradientmachines/GradientMachine.cpp:79
#10 0x00007ffff6a1c433 in paddle_gradient_machine_load_parameter_from_disk () at /home/yuyang/BuildAgent3/work/d55918cf60d51073/paddle/capi/gradient_machine.cpp:67
#11 0x0000000000401557 in main ()
怀疑是不是模型参数文件也得修改?删掉right_fc的那些参数文件?