To labeling sentences, we'll use the Reuters newswire topics dataset. This is a dataset of 11,228 newswires from Reuters, labeled over 46 topics, published by Reuters in 1986. As with the IMDB dataset used in Chapter 6, Movie Reviews Sentiment Analysis Using Recurrent Neural Network, each wire is encoded as a sequence of word indexes.
Just as MNIST, Fashion-MNIST, and IMDB already used in the previous chapters, the Reuters dataset comes packaged as part of the Keras distribution, where there's also a detailed description of its content, as shown at the following link: https://keras.io/datasets/.
To import the Reuters dataset in the Python environment, the following code must be used:
from keras.datasets import reuters
(XTrain, YTrain), (XTest, YTest) = reuters.load_data(path="reuters.npz",
...