class_docstr: Defines end to end MatchLSTM and Answer_Pointer network for Reading Comprehension
class_docstr_tok: ["Defines","end","to","end","MatchLSTM","and","Answer_Pointer","network","for","Reading","Comprehension"]
docstr: Function to set up the end 2 end reading comprehension model
docstr_tok: ["Function","to","set","up","the","end","2","end","reading","comprehension","model"]
code: def create_model(self):
      """
      Function to set up the end 2 end reading comprehension model
  
      """
      # Embedding Layer
      embedding_lookup = tf.Variable(
          self.embeddings,
          name="word_embeddings",
          dtype=tf.float32,
          trainable=False,
      )
      # Embedding Lookups
      self.question_emb = tf.nn.embedding_lookup(
          embedding_lookup, self.question_ids, name="question_embed"
      )
  
      self.para_emb = tf.nn.embedding_lookup(
          embedding_lookup, self.para_ids, name="para_embed"
      )
  
      # Apply dropout after embeddings
      self.question = tf.nn.dropout(self.question_emb, self.dropout)
      self.para = tf.nn.dropout(self.para_emb, self.dropout)
  
      # Encoding Layer
      # Share weights of pre-processing LSTM layer with both para and
      # question
      with tf.variable_scope("encoded_question"):
          self.lstm_cell_question = tf.nn.rnn_cell.BasicLSTMCell(
              self.hidden_size, state_is_tuple=True
          )
  
          self.encoded_question, _ = tf.nn.dynamic_rnn(
              self.lstm_cell_question,
              self.question,
              self.question_length,
              dtype=tf.float32,
          )
  
      with tf.variable_scope("encoded_para"):
          self.encoded_para, _ = tf.nn.dynamic_rnn(
              self.lstm_cell_question,
              self.para,
              self.para_length,
              dtype=tf.float32,
          )
  
      # Define Match LSTM and Answer Pointer Cells
      with tf.variable_scope("match_lstm_cell"):
          self.match_lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(
              self.hidden_size, state_is_tuple=True
          )
  
      with tf.variable_scope("answer_pointer_cell"):
          self.lstm_pointer_cell = tf.nn.rnn_cell.BasicLSTMCell(
              self.hidden_size, state_is_tuple=True
          )
  
      print("Match LSTM Pass")
      # Match LSTM Pass in forward direction
      self.unroll_with_attention(reverse=False)
      self.encoded_para_reverse = tf.reverse(
          self.encoded_para, axis=[1]
      )
      # Match LSTM Pass in reverse direction
      self.unroll_with_attention(reverse=True)
      # Apply dropout
      self.stacked_lists = tf.concat(
          [
              tf.nn.dropout(
                  self.stacked_lists_forward,
                  tf.maximum(self.dropout, 0.8),
              ),
              tf.nn.dropout(
                  self.stacked_lists_reverse,
                  tf.maximum(self.dropout, 0.8),
              ),
          ],
          1,
      )
  
      # Answer pointer pass
      self.logits = self.answer_pointer_pass()
      if self.inference_only is False:
          print("Settting up Loss")
          # Compute Losses
          loss_1 = tf.nn.sparse_softmax_cross_entropy_with_logits(
              logits=self.logits[0], labels=self.labels[:, 0]
          )
  
          loss_2 = tf.nn.sparse_softmax_cross_entropy_with_logits(
              logits=self.logits[1], labels=self.labels[:, 1]
          )
          # Total Loss
          self.loss = tf.reduce_mean(loss_1 + loss_2)
          self.learning_rate = tf.constant(0.002)
  
          print("Set up optmizer")
          # Optmizer
          self.optimizer = tf.train.AdamOptimizer(
              self.learning_rate
          ).minimize(self.loss, global_step=self.global_step)
  
file_path: nlp-architect/examples/reading_comprehension/match_lstm_mrc/matchlstm_ansptr.py
imports: from __future__ import division
  from __future__ import print_function
  import re
  from collections import Counter
  import numpy
  import tensorflow
  from nlp_architect.utils.text import SpacyInstance
label_desc: Use image node_id 3 for calling the MatchLSTMAnswerPointer obj's underlying member method code with example usage: obj.create_model() without return types