-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Description
I think we need to address the problem below before merging startup program and main program into a single program:
-
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. -
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)
Metadata
Metadata
Assignees
Labels
No labels