Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Re-write Chapter 1 in Book to use new Fluid API #524

Merged
merged 4 commits into from
May 31, 2018
Merged

Re-write Chapter 1 in Book to use new Fluid API #524

merged 4 commits into from
May 31, 2018

Conversation

daming-lu
Copy link
Contributor

Both Jupyter and train.py are working. See the attached screenshots 😀

screen shot 2018-05-30 at 4 59 21 pm
screen shot 2018-05-30 at 5 04 37 pm

@daming-lu daming-lu changed the base branch from develop to high-level-api-branch May 31, 2018 00:15
Copy link
Contributor

@jetfuel jetfuel left a 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
Copy link
Contributor

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):
Copy link
Contributor

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:
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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)

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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?

@daming-lu daming-lu merged commit 742ea42 into PaddlePaddle:high-level-api-branch May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants