Skip to content

Update save inference model to support dygraph#25894

Merged
guoshengCS merged 51 commits intoPaddlePaddle:developfrom
LiuChiachi:update_save_inference_model_to_support_dygraph
Aug 25, 2020
Merged

Update save inference model to support dygraph#25894
guoshengCS merged 51 commits intoPaddlePaddle:developfrom
LiuChiachi:update_save_inference_model_to_support_dygraph

Conversation

@LiuChiachi
Copy link
Contributor

@LiuChiachi LiuChiachi commented Aug 3, 2020

PR types

New features

PR changes

APIs

Describe

Update save_inference_model in Hapi to support dygraph. And it will be no longer exposed to users, and users can use save, and set training=False to save inference model.

@paddle-bot-old
Copy link

paddle-bot-old bot commented Aug 3, 2020

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@LiuChiachi LiuChiachi force-pushed the update_save_inference_model_to_support_dygraph branch from 7d9806f to fa11228 Compare August 21, 2020 03:54

The parameters contains all the trainable Variable, will save to
a file with suffix ".pdparams".
If `for_inference` is set to Fasle, the parameters saved contain all

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False拼写错误

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!

path (str): The file prefix to save model. The format is
'dirname/file_prefix' or 'file_prefix'. if empty str. A exception
will be raised.
for_inference (bool): Whether to save inference model only. Default: False.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是一个可选参数,有默认值

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks!

def __init__(self):
super(MyNet, self).__init__()
self._fc = fluid.dygraph.Linear(784, 1, act='softmax')
import paddle.incubate.hapi as hapi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后续需要按照我们的新目录更新下

XiaoguangHu01
XiaoguangHu01 previously approved these changes Aug 24, 2020
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以先合入,再提个PR修改下。

def save(self, path):
"""
This function saves parameters, optimizer infomation to path.
def save(self, path, for_inference=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for_inference=False -> training=True
建议跟组网类的API的参数保持一致,用training这个参数标识训练和预测

saxon-zh
saxon-zh previously approved these changes Aug 24, 2020
Copy link

@saxon-zh saxon-zh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LiuChiachi LiuChiachi dismissed stale reviews from saxon-zh and XiaoguangHu01 via 3e6f384 August 24, 2020 11:34
XiaoguangHu01
XiaoguangHu01 previously approved these changes Aug 25, 2020
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants