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

How to initialize a Fluid program? #10177

Closed
helinwang opened this issue Apr 24, 2018 · 1 comment
Closed

How to initialize a Fluid program? #10177

helinwang opened this issue Apr 24, 2018 · 1 comment

Comments

@helinwang
Copy link
Contributor

helinwang commented Apr 24, 2018

I think we need to address the problem below before merging startup program and main program into a single program:

  1. Init reader when doing inference
    An inference program will run repeatedly, but we may have a reader inside an inference program, it should be initialized only once, not every time when the inference program runs. Merging the startup program and the main program essentially runs the initialization operators on every run.

  2. Load parameters inside the Fluid program when doing inference.
    The V4 API proposal proposes to load parameters outside of the Fluid program:

    infer.py

    x = fluid.Tensor(name='x', shape=[13], dtype='float32')
    y_predict = fluid.layers.fc(name='y_predict', input=x, size=1, act=None)
    return y_predict

    main.py

    program = fluid.compile('./infer.py', params='./params')
    inputs = {
      'x': [2,4,64,36,7,4,3,2,4,6,5,9,8]
    }
    results = program.run(input=inputs)

    It would be more coherent with the Fluid design if the parameter loading is inside the Fluid program:

    infer.py

    fluid.load_parameters("./params.recordio")
    x = fluid.Tensor(name='x', shape=[13], dtype='float32')
    y_predict = fluid.layers.fc(name='y_predict', input=x, size=1, act=None)
    return y_predict

    main.py

    program = fluid.compile('./infer.py')
    program.init()
    inputs = {
      'x': [2,4,64,36,7,4,3,2,4,6,5,9,8]
    }
    results = program.run(input=inputs)
@helinwang helinwang changed the title Does Imperative Fluid need a way to init program(e.g., running startup program)? How to initialize a Fluid program? Apr 24, 2018
@shanyi15
Copy link
Collaborator

您好,此issue在近一个月内暂无更新,我们将于今天内关闭。若在关闭后您仍需跟进提问,可重新开启此问题,我们将在24小时内回复您。因关闭带来的不便我们深表歉意,请您谅解~感谢您对PaddlePaddle的支持!
Hello, this issue has not been updated in the past month. We will close it today for the sake of other user‘s experience. If you still need to follow up on this question after closing, please feel free to reopen it. In that case, we will get back to you within 24 hours. We apologize for the inconvenience caused by the closure and thank you so much for your support of PaddlePaddle Group!

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

No branches or pull requests

2 participants