Modify sentiment analysis book chapter #539
Modify sentiment analysis book chapter #539nickyfantasy merged 4 commits intoPaddlePaddle:high-level-api-branchfrom
Conversation
| parameters=parameters, | ||
| update_equation=adam_optimizer) | ||
| ``` | ||
| Notice for loading and reading IMDB data, it could take up to 1 minute. Please be patient. |
There was a problem hiding this comment.
Does it always take 1 minute to load or just the first time?
| result = trainer.test(reader=test_reader, feeding=feeding) | ||
| print "\nTest with Pass %d, %s" % (event.pass_id, result.metrics) | ||
| if isinstance(event, fluid.EndStepEvent): | ||
| print("Step {0}, Epoch {1} Metrics {2}".format( |
There was a problem hiding this comment.
This will print at every single step. It is too excessive. Can you change to every 100 steps or something like that?
There was a problem hiding this comment.
since we only run 10 steps in jupyter, i think it is fine to print all 10 steps. In train.py, I make it print every 10 steps
| print("Step {0}, Epoch {1} Metrics {2}".format( | ||
| event.step, event.epoch, map(np.array, event.metrics))) | ||
|
|
||
| if event.step == 10: |
There was a problem hiding this comment.
This is basically saying we will only train 10 steps.
There is no need to call trainer.stop() since this is not a test.
There was a problem hiding this comment.
this model will run like for 200steps and couple minutes with 1 epoch, I want to stop it fast so that user can see inference result in jupyter notebook
There was a problem hiding this comment.
In train.py, it will continue to run
There was a problem hiding this comment.
How long does it take to run? If the training takes about 10 minutes or so, we can let the users know the time cost.
06.understand_sentiment/README.md
Outdated
| lod = [[3, 4, 2]] | ||
| base_shape = [1] | ||
| # The range of random integers is [low, high] | ||
| tensor_words = fluid.create_random_int_lodtensor( |
There was a problem hiding this comment.
Here is using a random vector. We should use a real example instead. (if possible.)
There was a problem hiding this comment.
Yes, I just did it with 3 sentences 'read the book forget the movie', 'this is a great movie', 'this is very bad'
|
|
||
| CLASS_DIM = 2 | ||
| EMB_DIM = 128 | ||
| HID_DIM = 512 |
There was a problem hiding this comment.
I really think we should use hidden and correct the English misspellings sometime. For example from paddle.v2.plot import Ploter
There was a problem hiding this comment.
But it is not an urgent problem now.
06.understand_sentiment/README.md
Outdated
| To reiterate, we can either invoke `convolution_net` or `stacked_lstm_net`. In below steps, we will go with `convolution_net`. | ||
|
|
||
| The above stacked bidirectional LSTM network extracts high-level features and maps them to a vector of the same size as the categories. `paddle.activation.Softmax` function or classifier is then used for calculating the probability of the sentence belonging to each category. | ||
| Next we define a `inference_program` that simply uses `convolution_net` to predict output with the input from `fluid.layer.data`. |
| cost = fluid.layers.cross_entropy(input=prediction, label=label) | ||
| avg_cost = fluid.layers.mean(cost) | ||
| accuracy = fluid.layers.accuracy(input=prediction, label=label) | ||
| return [avg_cost, accuracy] |
There was a problem hiding this comment.
Here we should emphasize that the 1st returned parameter must be cost
| parameters=parameters, | ||
| update_equation=adam_optimizer) | ||
| ``` | ||
| Notice for loading and reading IMDB data, it could take up to 1 minute. Please be patient. |
There was a problem hiding this comment.
Mr. Minaj is a true gentleman 👍
|
Thanks @nickyfantasy for your efforts. |
|
LGTM |
No description provided.