the label associated with an example is an integer between and -- topic indextrain_labels[ preparing the data you can vectorize the data with the exact same code as in the previous example listing encoding he dat import numpy as np def vectorize_sequences(sequencesdimension= )results np zeros((len(sequences)dimension)for isequence in enumerate(sequences)results[isequence return results vectorized training data x_train vectorize_sequences(train_datax_test vectorize_sequences(test_datavectorized test data to vectorize the labelsthere are two possibilitiesyou can cast the label list as an integer tensoror you can use one-hot encoding one-hot encoding is widely used format for categorical dataalso called categorical encoding for more detailed explanation of one-hot encodingsee section in this caseone-hot encoding of the labels consists of embedding each label as an all-zero vector with in the place of the label index here' an exampledef to_one_hot(labelsdimension= )results np zeros((len(labels)dimension)for ilabel in enumerate(labels)results[ilabel return results one_hot_train_labels to_one_hot(train_labelsone_hot_test_labels to_one_hot(test_labelsvectorized training labels vectorized test labels note that there is built-in way to do this in keraswhich you've already seen in action in the mnist examplefrom keras utils np_utils import to_categorical one_hot_train_labels to_categorical(train_labelsone_hot_test_labels to_categorical(test_labelsbuilding your network this topic-classification problem looks similar to the previous movie-review classification problemin both casesyou're trying to classify short snippets of text but there is new constraint herethe number of output classes has gone from to the dimensionality of the output space is much larger in stack of dense layers like that you've been usingeach layer can only access information present in the output of the previous layer if one layer drops some information licensed to