Inference

We will now load the saved model file and test it with sample data from the input text that was not seen by the model. We will load the logits tensor from the model, and use that to infer the summary text prediction output on unseen or test data:

INFO:tensorflow:Restoring parameters from /tmp/models/best_so_far_model.ckpt

Text
Word Ids:    [33, 687, 145, 2047, 33, 5800, 1133, 2016, 19, 526, 6626, 3, 6842, 526, 1716, 5573, 11024, 128, 526, 3591, 1607, 1272, 3024, 19, 81, 8167, 19, 774, 526, 594, 1716, 65, 10590, 11026]

Input Words: a taiwan official gave a cautious welcome tuesday to the idea of having the olympic torch through the island if beijing were to be chosen to host the #### olympic games . Summary Word Ids: [687, 605, 19, 81, 39, 740] Response Words: taiwan launches to be <unk> wins Ground Truth: cautiously welcomes idea of allowing passage of
olympic torch

We will also run the inference on the training data. While the predictions or summary of the unseen input text is far from the ground truth, the predictions for the training data are quite close as the following output shows:

INFO:tensorflow:Restoring parameters from /tmp/models/best_so_far_model.ckpt

Text
Word Ids:    [10651, 1190, 910, 2324, 457, 178, 1203, 3909, 126, 7746, 909, 910, 29, 33, 4642, 745, 10903, 581, 13, 33, 911, 2796, 19, 2156, 115, 526, 11024, 1871, 10589, 5672, 702, 10590, 11026]

Input Words: japanese share prices closed #.## percent higher thursday as easing oil prices and a weaker yen buoyed confidence in a market continuing to recover from the shock , dealers said . Summary Word Ids: [548, 492, 493, 457, 178, 457] Response Words: tokyo shares close #.## percent #.## Ground Truth: tokyo stocks close up #.## percent

It should be noted that the poor performance of the model with the test data can be attributed to the small dataset that we utilized for the training (with a training size of 3,000 samples). The reader can use the same model to train on a larger dataset, probably on a GPU, to get better results.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset