C-API是否支持paddle-v2训练得到的模型预测
Created by: Bella-Zhao
我用paddle-v2训练好了一个模型,网络配置如下:
data = paddle.layer.data("word", paddle.data_type.integer_value_sequence(input_dim))
emb = paddle.layer.embedding(input=data, size=emb_dim,
param_attr=paddle.attr.Param(name='embeddings', is_static=True))
fc1 = paddle.layer.fc(input=emb, size=hid_dim, act=linear, bias_attr=bias_attr)
lstm1 = paddle.layer.lstmemory(input=fc1, act=relu, bias_attr=bias_attr, layer_attr=layer_attr)
inputs = [fc1, lstm1]
for i in range(2, stacked_num + 1):
fc = paddle.layer.fc(
input=inputs,
size=hid_dim,
act=linear,
param_attr=para_attr,
bias_attr=bias_attr)
lstm = paddle.layer.lstmemory(
input=fc,
reverse=(i % 2) == 0,
act=relu,
bias_attr=bias_attr,
layer_attr=layer_attr)
inputs = [fc, lstm]
fc_last = paddle.layer.pooling( input=inputs[0], pooling_type=paddle.pooling.Max())
lstm_last = paddle.layer.pooling(input=inputs[1], pooling_type=paddle.pooling.Max())
output = paddle.layer.fc(
input=[fc_last, lstm_last],
size=class_dim,
act=paddle.activation.Softmax(),
bias_attr=bias_attr,
param_attr=para_attr)
现在想将预测过程包装成一个rpc服务,用capi调用上述训练好的模型预测,在参考https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/capi/examples/model_inference/dense/trainer_config.py 生成配置的过程中发现,配置文件的代码风格还是v1的。
请问:capi是否支持用paddle-v2训练出的模型?如果支持,我的v2配置如何改写成v1的?