Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paddlepaddle保存的静态模型通过paddle.jit.load载入成 translated_layer,关于translated_layer的使用问题 #50003

Closed
kevinfu1717 opened this issue Jan 22, 2023 · 5 comments
Assignees
Labels
status/close 已关闭 type/new-feature 确认的新需求

Comments

@kevinfu1717
Copy link

kevinfu1717 commented Jan 22, 2023

请提出你的问题 Please ask your question

载入静态模型到 translated_layer后无法使用。代码如下:

import paddle
translated_layer = paddle.jit.load("inference_model/yolov3_darknet53_270e_coco/model")##已经载入成功
program = translated_layer.program()
print((program))
translated_layer.eval()
x = paddle.zeros([1,3, 416,416], 'float32')
pred = translated_layer(x)
print(pred)
————————————————————————
Error Msg:
Traceback (most recent call last):
File "E:/PYTHON/trainPaddleDetection/01/inferOutput.py", line 13, in
pred = translated_layer(x)
File "D:\ProgramData\Anaconda3\envs\paddle21\lib\site-packages\paddle\fluid\dygraph\layers.py", line 930, in call
return self._dygraph_call_func(*inputs, **kwargs)
File "D:\ProgramData\Anaconda3\envs\paddle21\lib\site-packages\paddle\fluid\dygraph\layers.py", line 915, in _dygraph_call_func
outputs = self.forward(*inputs, **kwargs)
File "D:\ProgramData\Anaconda3\envs\paddle21\lib\site-packages\paddle\fluid\dygraph\io.py", line 1329, in i_m_p_l
return _run_dygraph(self, input, program_holder)
File "D:\ProgramData\Anaconda3\envs\paddle21\lib\site-packages\paddle\fluid\dygraph\io.py", line 877, in _run_dygraph
_valid_vars(double_grad_vars), *attrs)
ValueError: (InvalidArgument) The conv2d Op's Input Variable Input contains uninitialized Tensor.
[Hint: Expected t->IsInitialized() == true, but received t->IsInitialized():0 != true:1.] (at ..\paddle\fluid\framework\operator.cc:2094)
[operator < conv2d > error] [operator < run_program > error]

Question1: Input contains uninitialized Tensor,但如何初始化没找到头绪,文档也是类似我这个的使用:https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/jit/TranslatedLayer_cn.html 好像也没有哪里有初始化。

Question2: translated_layer 文档说是layer的继承类,那eval时,是否可以取中间层的结果出来,要如何操作?

thank you

@paddle-bot
Copy link

paddle-bot bot commented Jan 22, 2023

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网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!

@kevinfu1717
Copy link
Author

#47908 这个内部api好像说能用,但追去源码并没有这个函数

@zhangting2020
Copy link
Contributor

您好,
Question1: 这个报错使用的是Paddle哪个版本?这个版本运行https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/jit/TranslatedLayer_cn.html 链接中的示例代码能否跑通?

Question2: 这个IntermediateLayerGetter 接口目前并没有在正式版本中发布,如果需要使用只能暂时通过安装develop版本使用,先参考这个脚本中的用法即可。https://github.com/PaddlePaddle/Paddle/blob/39adb22aba6520ac2147ea320411dc94fec55f57/python/paddle/fluid/tests/unittests/test_IntermediateLayerGetter.py

@kevinfu1717
Copy link
Author

Thanks for your reply.
Question1 : The version is "paddlepaddle-gpu 2.3.2.post101";
链接中的示例代码可以跑通,能打印训练loss:
Epoch 0 batch 0: loss = 2.200899839401245
Epoch 0 batch 1: loss = 2.508420467376709
Epoch 0 batch 2: loss = 2.71962308883667...

其中paddle.jit.load("inference_model/yolov3_darknet53_270e_coco/model")的模型是通过以下代码输出的:

"python E:/PYTHON/PaddleDetection-release-2.5/tools/export_model.py
-c picodet_l_416_coco_lcnet.yml
-o weights=output/picodet_l_416_coco_lcnet/model_final.pdparams
--output_dir=./inference_model"

Question2: 那正式版中是否有其他api可以实现eval时,是否可以取中间层的结果出来?

@zhangting2020
Copy link
Contributor

Question1:建议参考下PaddleDetection的这个介绍,看是否能运行成功?https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.5/deploy/python

Question2:目前暂时还没有正式版的API,需要要等后续发版计划。

@paddle-bot paddle-bot bot added status/following-up 跟进中 type/new-feature 确认的新需求 and removed status/new-issue 新建 type/question 用户提问 labels Jan 29, 2023
@paddle-bot paddle-bot bot added status/close 已关闭 and removed status/following-up 跟进中 labels Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/close 已关闭 type/new-feature 确认的新需求
Projects
None yet
Development

No branches or pull requests

2 participants