CAPI load python train 出的模型
Created by: zhglzh
merge model碰到问题,CAPI加载时直接报了异常,希望有个从python train出模型,然后使用capi加载的完整示例
*** Aborted at 1512136556 (unix time) try "date -d @1512136556" if you are using GNU date ***
PC: @ 0x0 (unknown)
*** SIGSEGV (@0x60) received by PID 22477 (TID 0x7ff216ba08c0) from PID 96; stack trace: ***
@ 0x7ff215d94330 (unknown)
@ 0x7ff212921959 paddle::GradientMachine::loadParameters()
@ 0x7ff21277c123 paddle_gradient_machine_load_parameter_from_disk
@ 0x7ff216272152 adu::planning::MLPOccassionModel::load()
@ 0x7ff216272b14 adu::planning::MLPOccassionModel::MLPOccassionModel()
@ 0x419c95 adu::planning::TestSuite_occassion_model_mlp_test_Test::TestBody()
@ 0x7ff21679a6b6 testing::internal::HandleSehExceptionsInMethodIfSupported<>()
@ 0x7ff2167954dc testing::internal::HandleExceptionsInMethodIfSupported<>()
@ 0x7ff216781cad testing::Test::Run()
@ 0x7ff216782446 testing::TestInfo::Run()
@ 0x7ff216782a34 testing::TestCase::Run()
@ 0x7ff2167878ee testing::internal::UnitTestImpl::RunAllTests()
@ 0x7ff21679bc08 testing::internal::HandleSehExceptionsInMethodIfSupported<>()
@ 0x7ff216796488 testing::internal::HandleExceptionsInMethodIfSupported<>()
@ 0x7ff216786682 testing::UnitTest::Run()
@ 0x41996f main
@ 0x7ff2149f2f45 __libc_start_main
@ 0x419baf (unknown)
@ 0x0 (unknown)
Segmentation fault (core dumped)
代码如下:
def event_handler(event):
"""
print msg
"""
if isinstance(event, paddle.event.EndIteration):
if event.batch_id % 100 == 0:
print "Pass %d, Batch %d, Cost %f" % (
event.pass_id, event.batch_id, event.cost)
if isinstance(event, paddle.event.EndPass):
if event.pass_id % 1 == 0:
param_file = 'params_pass_%d' % event.pass_id
with gzip.open(param_file + '.tar.gz', 'w') as f:
trainer.save_parameter_to_tar(f)
merge_v2_model(y_predict, param_file + '.tar.gz', param_file + '.bin')
result = trainer.test(
reader=paddle.batch(ds_all.create_reader(), batch_size=2),
feeding=feeding)
print "Test %d, Cost %f" % (event.pass_id, result.cost)