-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Re-write Chapter 1 in Book to use new Fluid API #524
Re-write Chapter 1 in Book to use new Fluid API #524
Conversation
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if we need to terminate early. Fit a line is pretty small.
train_title = "Train cost" | ||
test_title = "Test cost" | ||
plot_cost = Ploter(train_title, test_title) | ||
|
||
step = 0 |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this line do?
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.
This will show the image inline in Jupyter notebook, otherwise it shows something like Figure(640x480)
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.
It helps with plotting the graphics inline.
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.
and it needs to be inside of a python block?
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.
Yes.
```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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
to do "inference"?
``` | ||
|
||
### 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel "use the inference_program to setup the train_program" little bit confusing because we did not show inference_program until later
@@ -116,49 +117,58 @@ When training complex models, we usually have one more split: the validation set | |||
|
|||
`fit_a_line/trainer.py` demonstrates the training using [PaddlePaddle](http://paddlepaddle.org). | |||
|
|||
### Initialize PaddlePaddle | |||
### Datafeeder Configuration |
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.
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 😀