mirror of
https://github.com/PaddlePaddle/PaddleClas.git
synced 2025-06-03 21:55:06 +08:00
fix save var doc
This commit is contained in:
parent
b96ea72f0d
commit
8560e51365
@ -45,7 +45,15 @@ VALID:
|
||||
|
||||
>>
|
||||
* Q: What should I do if I want to transform the weights' format from `pdparams` to an earlier version(before Paddle1.7.0), which consists of the scattered files?
|
||||
* A: You can use `fluid.load` to load the `pdparams` weights and use `fluid.io.save_vars` to save the weights as scattered files.
|
||||
* A: You can use `fluid.load` to load the `pdparams` weights and use `fluid.io.save_vars` to save the weights as scattered files. The demo is as follows. Finally all the scattered files will be saved in the path `path_to_save_var`.
|
||||
```
|
||||
fluid.load(
|
||||
program=infer_prog, model_path=args.pretrained_model, executor=exe)
|
||||
state = fluid.io.load_program_state(args.pretrained_model)
|
||||
def exists(var):
|
||||
return var.name in state
|
||||
fluid.io.save_vars(exe, "./path_to_save_var", infer_prog, predicate=exists)
|
||||
```
|
||||
|
||||
|
||||
>>
|
||||
|
@ -45,7 +45,15 @@ VALID:
|
||||
|
||||
>>
|
||||
* Q: 如果想将保存的`pdparams`模型参数文件转换为早期版本(Paddle1.7.0之前)的零碎文件(每个文件均为一个单独的模型参数),该怎么实现呢?
|
||||
* A: 可以首先导入`pdparams`模型,之后使用`fluid.io.save_vars`函数将模型保存为零散的碎文件。
|
||||
* A: 可以首先导入`pdparams`模型,之后使用`fluid.io.save_vars`函数将模型保存为零散的碎文件。示例代码如下,最终所有零散文件会被保存在`path_to_save_var`目录下。
|
||||
```
|
||||
fluid.load(
|
||||
program=infer_prog, model_path=args.pretrained_model, executor=exe)
|
||||
state = fluid.io.load_program_state(args.pretrained_model)
|
||||
def exists(var):
|
||||
return var.name in state
|
||||
fluid.io.save_vars(exe, "./path_to_save_var", infer_prog, predicate=exists)
|
||||
```
|
||||
|
||||
|
||||
>>
|
||||
|
Loading…
x
Reference in New Issue
Block a user