python预测时CreateSparseMatrix出 core
Created by: 20092136
以下是我使用 python 版本预测模块的方式:
from py_paddle import swig_paddle, DataProviderConverter
from paddle.trainer.PyDataProvider2 import *
from paddle.trainer.config_parser import *
def load_test_data():
test_data = []
with open('./test/sentiment/thirdparty/predictset.txt', 'r') as f:
for line in f:
arr = line.strip().split('\t')
label = arr[0]
seq = arr[1].split()
feat = arr[2].split()
test_data.append([map(int, seq), map(int, feat), int(label)])
print test_data
return test_data
return test_data
def main():
swig_paddle.initPaddle("--use_gpu=0")
conf = parse_config("./model_output/pass-00000/trainer_config.py", "")
network = swig_paddle.GradientMachine.createFromConfigProto(conf.model_config)
assert isinstance(network, swig_paddle.GradientMachine) # For code hint.
network.loadParameters("./model_output/pass-00000/")
converter = DataProviderConverter([integer_value_sequence(319085),
sparse_non_value_slot(6121), integer_value(888)])
TEST_DATA = load_test_data()
inArg = converter.convert(TEST_DATA)
其中TEST_DATA的一个 sample 以及错误信息如下打印所示:
I1107 11:40:57.545857 2794 Util.cpp:144] commandline: --use_gpu=0 I1107 11:40:57.545934 2794 Util.cpp:113] Calling runInitFunctions I1107 11:40:57.546272 2794 Util.cpp:126] Call runInitFunctions done. [WARNING 2016-11-07 11:40:57,588 default_decorators.py:40] please use keyword arguments in paddle config. [WARNING 2016-11-07 11:40:57,590 default_decorators.py:40] please use keyword arguments in paddle config. [INFO 2016-11-07 11:40:57,595 networks.py:1122] The input order is [seq, feat] [INFO 2016-11-07 11:40:57,595 networks.py:1129] The output order is [fc_ly_4] I1107 11:40:57.912839 2794 GradientMachine.cpp:123] Loading parameters from ./model_output/pass-00000/ [[[290, 2201, 554, 37, 142, 237, 78, 60, 171, 1483, 1615, 2201, 229, 237, 50, 9, 18, 0, 2238, 204, 7, 2785, 15, 131, 2, 53, 79, 173, 52, 30, 345, 752, 110, 81, 690, 483, 2432, 2201, 19, 483, 1732, 125, 1483, 483, 55, 3909, 125, 1483, 86, 181, 695, 415, 14, 3, 22476, 370, 173, 242, 3], [494, 1333, 737, 3421, 1030, 6105], 206]] F1107 11:40:57.991053 2794 CpuSparseMatrix.cpp:59] Check failed: newNnz <= newHeight * newWidth (6 vs. 0)
* Check failure stack trace: *
@ 0x7f3c8f1c8448 google::LogMessage::Fail() @ 0x7f3c8f1c83a0 google::LogMessage::SendToLog() @ 0x7f3c8f1c7e35 google::LogMessage::Flush() @ 0x7f3c8f1cabf6 google::LogMessageFatal::~LogMessageFatal() @ 0x7f3c8ede308a paddle::CpuSparseMatrix::resize() @ 0x7f3c8ede314f paddle::CpuSparseMatrix::CpuSparseMatrix() @ 0x7f3c8edf53ae paddle::Matrix::createSparseMatrix() @ 0x7f3c8ed6920e Matrix::createSparse() @ 0x7f3c8ed3bc8d _wrap_Matrix_createSparse @ 0x4b4cb9 PyEval_EvalFrameEx @ 0x4b6b28 PyEval_EvalCodeEx @ 0x4b5d10 PyEval_EvalFrameEx @ 0x4b5fb8 PyEval_EvalFrameEx @ 0x4b6b28 PyEval_EvalCodeEx @ 0x4b5d10 PyEval_EvalFrameEx @ 0x4b5fb8 PyEval_EvalFrameEx @ 0x4b6b28 PyEval_EvalCodeEx @ 0x4b6c52 PyEval_EvalCode @ 0x4e1c7d PyRun_FileExFlags @ 0x4e3501 PyRun_SimpleFileExFlags @ 0x4159dd Py_Main @ 0x7f3c92c9fbd5 __libc_start_main @ 0x414b71 (unknown) predict.sh: line 5: 2794 Aborted (core dumped) ./python27-gcc482/bin/python predict.py追查 源码至py_paddle.dataprovider_converter.SparseBinaryScanner.finish_scan中创建 SparseMatrix出错,请问有可能是什么原因?