-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
fix quick start for fluid #9660 #9820
Conversation
The format of this line seems not right. |
Have you tested the process in this doc? @seiriosPlus This is the first demo user will see, so we must ensure it can run properly. |
I read the corresponding v2 doc in https://github.com/PaddlePaddle/Paddle/blob/develop/doc/v2/getstarted/quickstart_en.rst and find the same ref: maybe it is a .rst grammar? I'm not sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前的代码量太多,超过100行了。快速开始里的代码(包括注释和空行,一共19行),是为了让用户安装完后,快速验证安装的版本是否正确,能否执行出正确的内容,所以代码量要控制。
这部分代码会放在首页:http://www.paddlepaddle.org/ ,因此比较重要。
当时V2版本为了达到这一目的,删掉了train部分,因为这部分的代码量相对较多。因此fluid版本中,也可以只保留inference部分。同时inference中的代码,也进行简化:
- 能合并的部分尽量合并,比如
inference_scope = fluid.core.Scope()
with fluid.scope_guard(inference_scope):
能合并成一行:
with fluid.scope_guard(fluid.core.Scope())
- 注释部分尽量精简,不用写很多
- train训练完的模型可以像V2一样,保存在某一个地方。
- main函数可以删掉。
收到 |
@luotao1 收到, 这块代码我跟 @jacquesqiao 龙飞老师讨论了以后, 计划将训练后的模型部分放在paddle dataset中, 快速开始中只保留infer 和 模型定义的代码 |
@jacquesqiao @luotao1 @shanyi15
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 目前代码有27行,我有一个更简单的版本(15行)供大家参考:
import paddle.fluid as fluid
import numpy
with fluid.scope_guard(fluid.core.Scope()):
exe = fluid.Executor(fluid.CPUPlace())
[inference_program, feed_target_names,fetch_targets] =
fluid.io.load_inference_model(paddle.dataset.uci_housing.fluid_model(), exe)
tensor_x = numpy.random.uniform(0, 10,[10, 13]).astype("float32")
result = exe.run(inference_program,
feed={feed_target_names[0]: tensor_x},
fetch_list=fetch_targets)
print("infer results: ", result[0])
将paddle.dataset.uci_housing.fluid_model()
用训练好的模型测试后,打印结果为
('infer results: ', array([[-20.94965 ],
[-22.025486 ],
[-17.864204 ],
[ -9.126383 ],
[ -4.4889793],
[-16.532032 ],
[ -3.5934944],
[-19.41196 ],
[-22.91457 ],
[ -7.709648 ]], dtype=float32))
- 27行的
.. code-block:: python
和28行中间要空一行,不然显示不出代码,https://github.com/seiriosPlus/Paddle/blob/d13ca96781d17bcf99b0ae443a433bcd72812381/doc/fluid/getstarted/quickstart_cn.rst - 最终的代码里面需要加一些简单注释
- 不能把路径写死,还是要采用原来的方式。ref:
install_steps
有什么问题么
@luotao1 |
同意采用真实数。
|
@luotao1 代码已重新优化 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for the quick start codes.
URL_MODEL = 'https://github.com/PaddlePaddle/book/raw/develop/01.fit_a_line/fit_a_line.tar' | ||
MD5_MODEL = '52fc3da8ef3937822fcdd87ee05c0c9b' | ||
|
||
FLUID_URL_MODEL = 'https://github.com/PaddlePaddle/book/raw/develop/01.fit_a_line/fluid/fit_a_line.fluid.tar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原来的路径是V2的路径。现在python/paddle/dataset
和python/paddle/v2/dataset
一样,如果修改一部分的话,会导致后面两者不太一样。是不是把其中的一个变成另一个的软连接比较好? @helinwang @dzhwinter @JiayiFeng @jacquesqiao
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我试过alias,alias的paddle.v2.dataset
package: from paddle.dataset import *
Python里写import paddle.v2.dataset
是没有问题,但是import paddle.v2.dataset.mnist
会报错。所以就没有用alias。
如果有Python解决方法那就最好了。
如果无法解决,我觉得我们deprecate paddle.v2.dataset
(不再更新),只更新paddle.dataset
也是可以。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
赞同 @helinwang , 如果后续专注于fluid及后续版本的开发,将v2进行独立是一个可行的方案
我把v2下的dataset删除了,把v2中的代码合并到了paddle.dataset中 @shanyi15 @luotao1 @helinwang |
请问这部分能做为一个单独的PR提么? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 关于v2 dataset的,可以再下一个PR中修改
fix quick start for fluid #9660