O'Reilly logo

Hands-On Natural Language Processing with Python by Rajalingappaa Shanmugamani, Rajesh Arumugam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sequence-to-sequence model

We will now combine the encoder and decoder to create the sequence-to-sequence model:

def seq2seq_model(input_data, target_en_data, dropout_prob, fr_len, en_len, max_en_len,             v_size, rnn_cell_size, n_layers, word2int_en, batch_size):    input_word_embeddings = tf.Variable(fr_embeddings_matrix, name="input_word_embeddings")    encoding_embed_input = tf.nn.embedding_lookup(input_word_embeddings, input_data)    encoding_op, encoding_st = encoding_layer(rnn_cell_size, fr_len,                                 n_layers, encoding_embed_input, dropout_prob)    decoding_input = process_encoding_input(target_en_data, word2int_en, batch_size)    decoding_embed_input = tf.nn.embedding_lookup(en_embeddings_matrix, decoding_input) tr_logits, inf_logits = decoding_layer(decoding_embed_input, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required