#test prediction class labels convert text sentiment labels (negative\positiveto binary encodings ( / test_y le transform(test_sentimentsview vector shapes print('max length of train review vectors:'max_lenprint('train review vectors shape:'train_x shapetest review vectors shape:'test_x shapemax length of train review vectors train review vectors shape( test review vectors shape( from the preceding code snippet and the outputit is clear that we encoded each text review into numeric sequence vector so that the size of each review vector is which is basically the maximum length of reviews from the training dataset we pad shorter reviews and truncate extra tokens from longer reviews such that the shape of each review is constant as depicted in the output we can now proceed with step and part of step of the classification workflow by introducing the embedding layer and coupling it with the deep network architecture based on lstms from keras models import sequential from keras layers import denseembeddingdropoutspatialdropout from keras layers import lstm embedding_dim dimension for dense embeddings for each token lstm_dim total lstm units model sequential(model add(embedding(input_dim=vocab_sizeoutput_dim=embedding_diminput_length=max_len)model add(spatialdropout ( )model add(lstm(lstm_dimdropout= recurrent_dropout= )model add(dense( activation="sigmoid")model compile(loss="binary_crossentropy"optimizer="adam"metrics=["accuracy"]the embedding layer helps us generate the word embeddings from scratch this layer is also initialized with some weights initially and this gets updated based on our optimizer similar to weights on the neuron units in other layers when the network tries to minimize the loss in each epoch thusthe embedding layer tries to optimize its weights such that we get the best word embeddings which will generate minimum error in the model and also capture semantic similarity and relationships among words how do we get the embeddingslet' consider we have review with terms ['movie''was''good'and vocab_map consisting of word to index mappings for words the word embeddings would be generated somewhat similar to figure -