Check failed: PySequence_Check(seq_)
Created by: Ayle3125
error:
$ sh train.sh I0305 02:03:21.065882 8688 Util.cpp:155] commandline: /usr/bin/../opt/paddle/bin/paddle_trainer --config=trainer_config.py --save_dir=./output --trainer_count=1 --log_period=1000 --dot_period=10 --num_passes=10 --use_gpu=false --show_parameter_stats_period=3000 I0305 02:03:21.066009 8688 Util.cpp:130] Calling runInitFunctions I0305 02:03:21.066169 8688 Util.cpp:143] Call runInitFunctions done. I0305 02:03:21.227655 8688 Trainer.cpp:170] trainer mode: Normal I0305 02:03:21.231375 8688 PyDataProvider2.cpp:257] loading dataprovider dataprovider::process I0305 02:03:21.233568 8688 PyDataProvider2.cpp:257] loading dataprovider dataprovider::process I0305 02:03:21.234155 8688 GradientMachine.cpp:134] Initing parameters.. I0305 02:03:21.242753 8688 GradientMachine.cpp:141] Init parameters done. I0305 02:03:23.682387 8690 ThreadLocal.cpp:37] thread use undeterministic rand seed:8691 F0305 02:03:23.682598 8690 PythonUtil.h:215] Check failed: PySequence_Check(seq_) *** Check failure stack trace: *** @ 0x7fc949c1adaa (unknown) @ 0x7fc949c1ace4 (unknown) @ 0x7fc949c1a6e6 (unknown) @ 0x7fc949c1d687 (unknown) @ 0x549546 paddle::py::SequenceHelper::SequenceHelper() @ 0x54972a paddle::DenseScanner::fill() @ 0x54ab01 paddle::SequenceScanner::fill() @ 0x54f7fc paddle::PyDataProvider2::getNextBatchInternal() @ 0x55467e paddle::DoubleBuffer::asyncLoadBatch() @ 0x7fc949720c80 (unknown) @ 0x7fc94aa596ba start_thread @ 0x7fc948e8682d (unknown) @ (nil) (unknown) /usr/bin/paddle: line 109: 8688 Aborted (core dumped) ${DEBUGGER} $MYDIR/../opt/paddle/bin/paddle_trainer ${@:2}
DataProvider:
from paddle.trainer.PyDataProvider2 import *
import sys
import numpy as np
TERM_NUM = 24
FORECASTING_NUM = 24
LABEL_VALUE_NUM = 4
def initHook(settings, file_list, **kwargs):
"""
Init hook is invoked before process data. It will set obj.slots and store data meta.
:param settings: global object. It will passed to process routine.
:type obj: object
:param file_list: the meta file object, which passed from trainer_config.py,but unused in this function.
:param kwargs: unused other arguments.
"""
del kwargs #unused
settings.pool_size = sys.maxint
#Use a time seires of the past as feature.
#Dense_vector's expression form is [float,float,...,float]
settings.input_types =[dense_vector_sequence(TERM_NUM) ,]
#There are next FORECASTING_NUM fragments you need predict.
#Every predicted condition at time point has four states.
for i in range(FORECASTING_NUM):
settings.input_types.append(integer_value(LABEL_VALUE_NUM))
@provider(
init_hook=initHook, cache=CacheType.CACHE_PASS_IN_MEM, should_shuffle=True)
def process(settings, file_name):
with open(file_name) as f:
#abandon fields name
f.next()
for row_num, line in enumerate(f):
speeds = map(int, line.rstrip('\r\n').split(",")[1:])
# Get the max index.
end_time = len(speeds)
# Scanning and generating samples
for i in range(TERM_NUM, end_time - FORECASTING_NUM):
# For dense slot
pre_spd = map(int, speeds[i - TERM_NUM:i])
# Integer value need predicting, values start from 0, so every one minus 1.
fol_spd = [j - 1 for j in speeds[i:i + FORECASTING_NUM]]
# Predicting label is missing, abandon the sample.
if -1 in fol_spd:
continue
yield [pre_spd] +fol_spd
def predict_initHook(settings, file_list, **kwargs):
settings.pool_size = sys.maxint
settings.input_types = [dense_vector(TERM_NUM)]
@provider(init_hook=predict_initHook, should_shuffle=False)
def process_predict(settings, file_name):
with open(file_name) as f:
#abandon fields name
f.next()
for row_num, line in enumerate(f):
speeds = map(int, line.rstrip('\r\n').split(","))
end_time = len(speeds)
pre_spd = map(float, speeds[end_time - TERM_NUM:end_time])
yield pre_spd
I use dense_vector_sequence(TERM_NUM)] insteat of [dense_vector(TERM_NUM)], so what's wrong is it? Could someone help?
@reyoung @cxwangyi