File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,33 @@ if __name__ == '__main__':
219
219
paddle.jit.save(net, 'inference_model/lenet')
220
220
```
221
221
222
+ Paddle 2.0 默认保存的权重格式为 ` *.pdiparams ` 后缀的文件。若因特殊需求,希望沿用旧版本的分离权重方式,请参考以下示例进行另存为。Paddle 2.0 兼容支持这种旧格式推理部署模型的加载。
223
+
224
+ ```
225
+ import paddle
226
+
227
+ if __name__ == '__main__':
228
+ paddle.enable_static()
229
+ place = paddle.CPUPlace()
230
+ exe = paddle.static.Executor(place)
231
+
232
+ # load combined params and model
233
+ program, _, _ = paddle.static.load_inference_model(
234
+ path_prefix='inference_model',
235
+ executor=exe,
236
+ model_filename='lenet.pdmodel',
237
+ params_filename='lenet.pdiparams')
238
+
239
+ # save as separate persistables
240
+ paddle.static.save_vars(
241
+ executor=exe,
242
+ dirname="separate_persistables",
243
+ main_program=program,
244
+ vars=None,
245
+ predicate=paddle.static.io.is_persistable)
246
+ ```
247
+
248
+
222
249
## 三、使用 Paddle 2.0 Python 接口预测部署
223
250
224
251
我们使用存储好的预测部署模型,借助 Python 2.0 接口执行预测部署。
You can’t perform that action at this time.
0 commit comments