Processing the input data

Text data cannot be fed directly into any neural network, since neural networks can understand only numbers. We will treat each word as a one-hot encoded vector of a length that is equal to the number of words present in each corpus. If the English corpus contains 1,000 words, the one-hot encoded vectors ve would be of a dimension of 1,000, that is, ve ∈ R1000 x 1.

We will read through the English and the French corpus and determine the number of unique words in each of them. We will also represent the words by index, and for a one-hot encoded vector for the word, the index corresponding to the word would be set to one, while the rest of the indices would be set to zero. For example, let's assume that in the English ...

Get Intelligent Projects Using Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.