March 2018
Intermediate to advanced
272 pages
7h 53m
English
In this function, we will be taking the dictionary we just built and one hot encoding the text of each phrase.
Once we're done, we will be left with three dictionaries. Each of them will be of dimension [number of texts * max sequence length * tokens]. If you squint, and think back to the simpler times of Chapter 10, Training LSTMs with Word Embeddings from Scratch, you can see this is really the same as the other NLP models we've done on the input side. We will define one hot encoding using the following code:
def one_hot_vectorize(data): input_chars = data['input_chars'] target_chars = data['target_chars'] input_texts = data['input_texts'] target_texts = data['target_texts'] max_encoder_seq_length = data['max_encoder_seq_length' ...