Re-write Chapter 1 in Book to use new Fluid API#524
Re-write Chapter 1 in Book to use new Fluid API#524daming-lu merged 4 commits intoPaddlePaddle:high-level-api-branchfrom daming-lu:fit_a_line_book_chapter
Conversation
jetfuel
left a comment
There was a problem hiding this comment.
Feel free to merge first and continue the second draft.
|
|
||
| ### Save Topology | ||
| ### Train Program Configuration | ||
| The train_program must return the avg_loss as its first returned parameter and then use the inference_program to setup the train_program |
There was a problem hiding this comment.
You might need to explain a bit more on the Train program topic.
|
|
||
| step = 0 | ||
|
|
||
| def event_handler_plot(event): |
There was a problem hiding this comment.
Since you are plotting the graph, why not keep using the event_handler_plot?
| print('loss is less than 10.0, stop') | ||
| trainer.stop() | ||
|
|
||
| if step >= 2000: |
There was a problem hiding this comment.
not sure if we need to terminate early. Fit a line is pretty small.
| test_title = "Test cost" | ||
| plot_cost = Ploter(train_title, test_title) | ||
|
|
||
| step = 0 |
There was a problem hiding this comment.
EndStepEvent provide step already. There is no need to create another variable to keep track of it.
| ### Start Training | ||
|
|
||
| ```python | ||
| %matplotlib inline |
There was a problem hiding this comment.
This will show the image inline in Jupyter notebook, otherwise it shows something like Figure(640x480)
There was a problem hiding this comment.
It helps with plotting the graphics inline.
There was a problem hiding this comment.
and it needs to be inside of a python block?
| ```python | ||
| paddle.init(use_gpu=False, trainer_count=1) | ||
| ``` | ||
| We first define data feeders for test and train. The feeder reads a `BATCH_SIZE` of data each time and feed them to the training/testing process. Users can shuffle a batch out of a `buf_size` in order to make the data random. |
There was a problem hiding this comment.
Users can shuffle a batch out of a buf_size is a bit confusing...
| ``` | ||
|
|
||
| ### Create Trainer | ||
| The trainer will take the train_program. |
There was a problem hiding this comment.
... train_program as input.
| ### Apply model | ||
| ### Inference | ||
|
|
||
| Initialize the Inferencer with the inference_program and the params_folder, which is where we saved our params |
There was a problem hiding this comment.
maybe it should be params_dirname instead of params_folder?
|
|
||
| #### 1. generate testing data | ||
| #### Setup the Inference Program. | ||
| Similar to the trainer.train, the Inferencer needs to take an inference_program to do inferring. |
|
|
||
| ### Save Topology | ||
| ### Train Program Configuration | ||
| The train_program must return the avg_loss as its first returned parameter and then use the inference_program to setup the train_program |
There was a problem hiding this comment.
I feel "use the inference_program to setup the train_program" little bit confusing because we did not show inference_program until later
| `fit_a_line/trainer.py` demonstrates the training using [PaddlePaddle](http://paddlepaddle.org). | ||
|
|
||
| ### Initialize PaddlePaddle | ||
| ### Datafeeder Configuration |
There was a problem hiding this comment.
All these sections including training and inference are under ##Dataset section, should we bring these 1 level up?
Both Jupyter and train.py are working. See the attached screenshots 😀