-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Modify sentiment analysis book chapter #539
Modify sentiment analysis book chapter #539
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it always take 1 minute to load or just the first time?
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 seems always
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In train.py, it will continue to run
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is using a random vector. We should use a real example instead. (if possible.)
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, I just did it with 3 sentences 'read the book forget the movie', 'this is a great movie', 'this is very bad'
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.
Tiny comments
|
||
CLASS_DIM = 2 | ||
EMB_DIM = 128 | ||
HID_DIM = 512 |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it is not an urgent problem now.
06.understand_sentiment/README.md
Outdated
|
||
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`. |
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.
an inference_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.
good grammar catch
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we should emphasize that the 1st returned parameter must be cost
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.
true
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mr. Minaj is a true gentleman 👍
Thanks @nickyfantasy for your efforts. |
LGTM |
No description provided.