paddle官网的异步读取数据的范例代码中,无法使用save_inference保存模型

mctunoxg  于 5个月前  发布在  其他
关注(0)|答案(8)|浏览(77)

bug描述 Describe the Bug

https://www.paddlepaddle.org.cn/documentation/docs/zh/1.8/advanced_guide/data_preparing/static_mode/use_py_reader.html
paddle官网的异步读取数据的范例代码中,无法使用save_inference保存模型
在以上实例代码中,每个epoch加上保存模型的代码,报错
fluid.io.save_inference_model(dirname="./modelm", feeded_var_names=['image'], target_vars=[train_loss], executor=exe)

其他补充信息 Additional Supplementary Information

No response

rur96b6h

rur96b6h1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档常见问题历史IssueAI社区 来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

oxcyiej7

oxcyiej72#

请问使用什么版本的Paddle和环境?有详细的错误信息吗?

wfypjpf4

wfypjpf43#

paddle1.8,提示变量不存在

e4yzc0pl

e4yzc0pl4#

INFO 2022-07-22 17:57:43,665 dataloader_auto_checkpoint.py:157] end dataloader epoch_no:0
Traceback (most recent call last):
File "test5.py", line 135, in
fluid.io.save_inference_model(dirname="./modelm", feeded_var_names=['image'], target_vars=[train_loss], executor=exe)
File "/opt/_internal/cpython-3.7.0/lib/python3.7/site-packages/paddle/fluid/io.py", line 1250, in save_inference_model
prepend_feed_ops(main_program, feeded_var_names)
File "/opt/_internal/cpython-3.7.0/lib/python3.7/site-packages/paddle/fluid/io.py", line 1046, in prepend_feed_ops
out = global_block.var(name)
File "/opt/_internal/cpython-3.7.0/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2392, in var
raise ValueError("var %s not in this block" % name)
ValueError: var image not in this block

tjrkku2a

tjrkku2a5#

for epoch_id in six.moves.range(1):
run_iterable(train_prog, exe, train_loss, train_loader)

run_iterable(test_prog, exe, test_loss, test_loader)

fluid.io.save_inference_model(dirname="./modelm", feeded_var_names=['image'], target_vars=[train_loss], executor=exe)

r7s23pms

r7s23pms6#

你好,能贴一段可复现的代码吗?

0lvr5msh

0lvr5msh7#

你好,请设置一下save_inference_model的main_program参数

68bkxrlz

68bkxrlz8#

多谢,添加main_program参数后,可以正常保存

相关问题