Skip to content

Add merge model scripts#5151

Merged
NHZlX merged 5 commits intoPaddlePaddle:developfrom
NHZlX:add_merge_model_scripts
Oct 27, 2017
Merged

Add merge model scripts#5151
NHZlX merged 5 commits intoPaddlePaddle:developfrom
NHZlX:add_merge_model_scripts

Conversation

@NHZlX
Copy link
Contributor

@NHZlX NHZlX commented Oct 27, 2017

Integrate the model config and model parameters into one file.

The model configuration file describes the model structure which ends with .py. The parameters file stores the parameters of the model which ends with .tar.gz.

@param net The output layer of the network
@param param_file Path of the model parameters(.tar.gz) which is stored by v2 api.
@param output_file Path of the merged file which will be generated

Usage:

from paddle.util.merge_model import merge_v2_model
# import your network configuration
from mobilenet import mobile_net
        
net = mobile_net(3*224*224, 102)
param_file = './param_pass_00000.tar.gz'
output_file = './output.paddle'
        
merge_v2_model(net, param_file, output_file)
@NHZlX NHZlX requested a review from Xreki October 27, 2017 03:37
from paddle.proto import ModelConfig_pb2
from paddle.v2.topology import Topology

def merge_model(net_out, param_file, output_file):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about name it merge_v2_model? I think it can only be used for v2 model.

ends with .py. The parameters file stores the parameters of the model
which ends with .tar.gz.

@param net_out the output layer of the network
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

net will be ok, _out is puzzling.

which ends with .tar.gz.

@param net_out the output layer of the network
@param param_file path of the model parameters file(a gzip file).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path of model parameters (.tar.gz) which is stored by v2 api


net_out = mobile_net(3*224*224, 102)
param_file = YOUR_MODEL_PARAM_PATH
output_file = OUTPUT_MERGED_FILE_PATH
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

param_file = param_pass_00000.tar.gz
output_file = out.paddle

Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and you need to merge the current develop branch.

@NHZlX NHZlX merged commit f63273b into PaddlePaddle:develop Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants