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

Building the graph

We will now combine all of the individual components created earlier to build the complete graph:

train_graph = tf.Graph()with train_graph.as_default():     input_data, targets, learning_rate, dropout_probs,                             en_len, max_en_len, fr_len =model_inputs()logits_tr, logits_inf = seq2seq_model(tf.reverse(input_data, [-1]), targets, dropout_probs,                        fr_len,en_len,max_en_len,                        len(en_word2int)+1,rnn_len, n_layers,                        en_word2int,batch_size)logits_tr = tf.identity(logits_tr.rnn_output, 'logits_tr')logits_inf = tf.identity(logits_inf.sample_id, name='predictions')seq_masks = tf.sequence_mask(en_len, max_en_len, dtype=tf.float32, name='masks')with tf.name_scope("optimizer"):    tr_cost = sequence_loss(logits_tr,targets,seq_masks) optimizer = ...

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