Implementing the embeddings-based NMT

We will need to make a few changes to the existing functions to cater for the embeddings layer. Firstly, process_input would process the input to have word indexes in different time steps, instead of the one-hot encoded vectors, as follows:

      def process_input(self,input_texts,target_texts=None,verbose=True):        encoder_input_data = np.zeros(            (len(input_texts), self.max_encoder_seq_length),            dtype='float32')        decoder_input_data = np.zeros(            (len(input_texts), self.max_decoder_seq_length),            dtype='float32')        decoder_target_data = np.zeros(            (len(input_texts), self.max_decoder_seq_length,1),            dtype='float32')        if self.mode == 'train':            for i, (input_text, target_text) in                     enumerate(zip(input_texts,target_texts)): for ...

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.