deep learning for text and sequences it' thus reasonable to learn new embedding space with every new task fortunatelybackpropagation makes this easyand keras makes it even easier it' about learning the weights of layerthe embedding layer listing inst ant iat ing an embedding layer from keras layers import embedding embedding_layer embedding( the embedding layer takes at least two argumentsthe number of possible tokens (here , maximum word indexand the dimensionality of the embeddings (here the embedding layer is best understood as dictionary that maps integer indices (which stand for specific wordsto dense vectors it takes integers as inputit looks up these integers in an internal dictionaryand it returns the associated vectors it' effectively dictionary lookup (see figure word index embedding layer figure the embedding layer corresponding word vector the embedding layer takes as input tensor of integersof shape (samplessequence_length)where each entry is sequence of integers it can embed sequences of variable lengthsfor instanceyou could feed into the embedding layer in the previous example batches with shapes ( (batch of sequences of length or ( (batch of sequences of length all sequences in batch must have the same lengththough (because you need to pack them into single tensor)so sequences that are shorter than others should be padded with zerosand sequences that are longer should be truncated this layer returns floating-point tensor of shape (samplessequence_ lengthembedding_dimensionalitysuch tensor can then be processed by an rnn layer or convolution layer (both will be introduced in the following sectionswhen you instantiate an embedding layerits weights (its internal dictionary of token vectorsare initially randomjust as with any other layer during trainingthese word vectors are gradually adjusted via backpropagationstructuring the space into something the downstream model can exploit once fully trainedthe embedding space will show lot of structure-- kind of structure specialized for the specific problem for which you're training your model let' apply this idea to the imdb movie-review sentiment-prediction task that you're already familiar with firstyou'll quickly prepare the data you'll restrict the movie reviews to the top , most common words (as you did the first time you worked with this datasetand cut off the reviews after only words the network will learn -dimensional embeddings for each of the , wordsturn the input integer licensed to