动转静存储存储格式不一问题
动转静存储存储格式不一问题
out_dygraph, static_layer = TracedLayer.trace(net, inputs=np.moveaxis(ip[0], (3), (1)))
static_layer.save_inference_model('./checkpoint_static/net', feed=[0], fetch=[0])
通过文档中描述方式将动态图模型转为静态图
当利用
paddle.static.load_inference_model()
恢复时报错,
paddle.static.load_inference_model()貌似只能恢复pdiparams格式的模型
貌似与文档代码样例不符
https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/04_dygraph_to_static/basic_usage_cn.html
版本2.0
您好,收到你的问题,正在查看,@chenwhql,帮忙看看,谢谢 @lu1kaifeng,你这个link好像不对
save和load得配合使用,生成combined model file。就是两个文件格式的 model 文件。具体生成过程得按下面这个方式来做,才会生成combined model file。
将模型及其参数保存到指定的路径。例如,path_prefix="/path/to/modelname" ,在调用 save_inference_model(path_prefix, feed_vars, fetch_vars, executor) 之后,你可以在 "/path/to" 目录下找到两个文件,分别是 "modelname.pdmodel" 和 "modelname.pdiparams",前者表示序列化之后的模型文件,后者表示序列化之后的参数文件。
https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/static/save_inference_model_cn.html#save-inference-model
https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/static/load_inference_model_cn.html#load-inference-model