PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
22.2k stars 5.57k forks source link

v2 c_api fc_layer check size error #10818

Closed yttbgf closed 6 years ago

yttbgf commented 6 years ago

offline train and infer result is ok, but online infer core: c++: CHECK_PADDLE(paddle_arguments_resize(_in_args, input_size)); // create matrix in cpu/gpu _ego_input = paddle_matrix_create(_BATCH_SIZE, _EGO_FEATURE_DIM, _use_gpu); _obs_input = paddle_matrix_create(_BATCH_SIZE, _GRID_FEATURE_DIM, _use_gpu); if (!_use_gpu) { CHECK_PADDLE(paddle_matrix_get_row(_ego_input, 0, &_cpu_input_ego)); CHECK_PADDLE(paddle_matrix_get_row(_obs_input, 0, &_cpu_input_obs)); } CHECK_PADDLE(paddle_arguments_set_value(_in_args, 0, _ego_input)); CHECK_PADDLE(paddle_arguments_set_value(_in_args, 1, _obs_input));

python: def build_ego_branch(self, x): act_func = 'relu' # 'sigmoid' 'relu' 'tanh' softsign softplus 'elu' 'prelu'

[1]

    unit_size = 8
    ego_model = layer.fc(size=unit_size,
                         input=x,
                         act=paddle.activation.Tanh(),
                         #act=paddle.activation.SoftSign(),
                         #kernel_regularizer=regularizers.l1(regular_factor),
                         #kernel_initializer='he_normal',
                         name='ego_dense1')

F0522 10:41:15.078356 14734 Matrix.cpp:2816] Check failed: a_col == b_row (8 vs. 46) Check failure stack trace: @ 0x2b59876a8f2d google::LogMessage::Fail() @ 0x2b59876ac9dc google::LogMessage::SendToLog() @ 0x2b59876a8a53 google::LogMessage::Flush() @ 0x2b59876adeee google::LogMessageFatal::~LogMessageFatal() @ 0x2b5987942260 paddle::CpuMatrix::mul() @ 0x2b598794dd09 paddle::CpuMatrix::mul() @ 0x2b5987773e1a paddle::FullyConnectedLayer::forward() @ 0x2b59877edb19 paddle::NeuralNetwork::forward() @ 0x2b59876a4e46 paddle_gradient_machine_forward @ 0x2b5982af372a adu::planning::BaseModel::predict() @ 0x2b5982ae9b6d adu::planning::OccassionModelFactory::predict() @ 0x43bd01 adu::planning::BaseModelTest_predict_Test::TestBody()

dzhwinter commented 6 years ago

Could you check the input data, please? Because the fc_layer shape checker in c_api has been used millions of times.

yttbgf commented 6 years ago

感谢@dangqingqing @dzhwinter .问题是2个: 1.离线训练时feed的输入层顺序和持久化模型时输入层的顺序不一定时是一致的,离线预测可以再指定feed列表,但是c_api infer时只能给出索引,2者顺序不一致时就可能出各种奇怪的core 打印网络结构 layer.parse_network(输出层)有 input_layers:按这个顺序来填充数据。 2.输入数据是dense_vector_sequence时,单层序列,c_api要提供1个paddle_matrix (序列元素个数,元素特征个数),其输入索引为K,同时seq_array = {0,元素个数}, 调用pos=paddle_ivector_create(seq_array,2,true,false) paddle_arguments_set_sequence_start_pos(in_args,K,0,pos)

typhoonzero commented 6 years ago

Closing due to low activity, feel free to reopen if you still encounter this issue.