October 2018
Intermediate to advanced
252 pages
6h 49m
English
In the first case, we will not use any pre-trained word embeddings from Keras. Keras provides an embedding layer that can be used for textual or natural language data. The input data should be numerically encoded so that each word is represented by a numerical or integer value. We can use the tokenizer API from Keras to do this. In a case where we use Keras APIs without the pre-trained embeddings, the embedding layer is initialized with random weights.
Let's first create sample documents and corresponding labels, which classify each document as positive or negative, as shown in this code snippet:
# define documentsdocuments = ['Well done!', 'Good work', 'Great effort', 'nice work', 'Excellent!', 'Weak', 'Poor effort!', 'not ...