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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.