Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluid版本训练好的模型如何进行合并? #10990

Closed
yeyupiaoling opened this issue May 29, 2018 · 7 comments
Closed

Fluid版本训练好的模型如何进行合并? #10990

yeyupiaoling opened this issue May 29, 2018 · 7 comments
Assignees
Labels
User 用于标记用户问题

Comments

@yeyupiaoling
Copy link
Contributor

在Android设备或者是Linux下,使用的预测模型是合并的模型,在V2版本中,预测模型是一个.tar.gz的文件。但是在fluid版本的预测模型不是这样的了。那么如何合并模型呢?

以下是V2的合并模型的代码:

from paddle.utils.merge_model import merge_v2_model

# import your network configuration
from mobilenet import mobile_net

net = mobile_net(3*224*224, 102, 1.0)
param_file = './mobilenet_flowers102.tar.gz'
output_file = './output.paddle'

merge_v2_model(net, param_file, output_file)
@luotao1
Copy link
Contributor

luotao1 commented May 29, 2018

请参考 http://www.paddlepaddle.org/docs/develop/documentation/fluid/zh/howto/inference/inference_support_in_fluid.html 中的“参数保存到同一个文件”

@chengduoZH chengduoZH added the User 用于标记用户问题 label May 29, 2018
@chengduoZH chengduoZH self-assigned this May 29, 2018
@yeyupiaoling
Copy link
Contributor Author

@luotao1
使用这个方式拿到的模型文件,能否像之前那样加载预测模型呢?

[inference_program, feed_target_names,
fetch_targets] = fluid.io.load_inference_model(save_dirname, exe)

上面的是Python的,下面C++的是否也是这样使用的?

const bool is_combined = false;
std::vector<std::vector<int64_t>> feed_target_shapes =
GetFeedTargetShapes(dirname, is_combined);

最后还有这个model_filename是什么意思?
image

谢谢

@yeyupiaoling
Copy link
Contributor Author

@luotao1
顺便问一下,编译Fluid Inference库 和 链接Fluid Inference库 这两个的区别是什么,或者说,这些是用来干什么的?跟这个http://www.paddlepaddle.org/docs/develop/mobile/zh//cross_compiling_for_android_cn.html 有什么区别?

@luotao1
Copy link
Contributor

luotao1 commented May 30, 2018

使用这个方式拿到的模型文件,能否像之前那样加载预测模型

请问,以前那样加载预测模型是指?

下面C++的是否也是这样使用的

C++的例子可以参考https://github.com/luotao1/fluid_inference_example/blob/master/example.cc#L43 我们最近会把inference的C++示例放入主干 @tensor-tang

编译Fluid Inference库 和 链接Fluid Inference库 这两个的区别是什么, 或者说,这些是用来干什么的?

这些是服务器端做预测使用的,你贴的链接是移动端预测用的。编译Fluid Inference库是指编译出libpaddle_fluid.so和相关的头文件,链接Fluid Inference库,是指在服务中怎么使用libpaddle_fluid.so。可以先参考上一条回答中的示例,近期我们会整理进主干。

@yeyupiaoling
Copy link
Contributor Author

@luotao1
如果model_filenameparams_filename都为None,那么save_inference_model的模型参数文件的一个文件夹,里面每个参数变量的文件,可以使用以下的方法加载这些文件,当时使用设置model_filename为None、params_filename为__params__时,也就是参数保存到同一个文件,下面的方法还可以用吗?

[inference_program, feed_target_names,
fetch_targets] = fluid.io.load_inference_model(save_dirname, exe)

因为我看到 编译Fluid Inference库 得到的文件跟编译安装所需的Android参不多,所以想问,Fluid版本的是否也可以编译Android的PaddlePaddle库
https://github.com/PaddlePaddle/Paddle/blob/develop/doc/mobile/cross_compiling_for_android_en.md#build-and-install

@luotao1
Copy link
Contributor

luotao1 commented May 30, 2018

  1. 参考 http://www.paddlepaddle.org/docs/develop/api/fluid/en/io.html#permalink-8-load_inference_model
    使用fluid.io.load_inference_model(save_dirname, exe, model_filename=None, params_filename=__params__) 进行加载。
  2. Fluid版本暂时无法编译Andorid的PaddlePaddle库。

@yeyupiaoling
Copy link
Contributor Author

@luotao1 收到,谢谢您的回答。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User 用于标记用户问题
Projects
None yet
Development

No branches or pull requests

3 participants