(passage, passage_len, question, question_len, cell, params, scope = "pointer_network")
Answer pointer network as proposed in https://arxiv.org/pdf/1506.03134.pdf.

    Args:
        passage:        RNN passage output from the bidirectional readout layer (batch_size, timestep, dim)
        passage_len:    variable lengths for passage length
        question:       RNN question output of shape (batch_size, timestep, dim) for question pooling
        question_len:   Variable lengths for question length
        cell:           rnn cell of type RNN_Cell.
        params:         Appropriate weight matrices for attention pooling computation

    Returns:
        softmax logits for the answer pointer of the beginning and the end of the answer span
Answer pointer network as proposed in https://arxiv.org/pdf/1506.03134.pdf.
Answer pointer network as proposed in https : // arxiv . org / pdf / 1506 . 03134 . pdf .
def pointer_net(passage, passage_len, question, question_len, cell, params, scope = "pointer_network"):
    '''
    Answer pointer network as proposed in https://arxiv.org/pdf/1506.03134.pdf.

    Args:
        passage:        RNN passage output from the bidirectional readout layer (batch_size, timestep, dim)
        passage_len:    variable lengths for passage length
        question:       RNN question output of shape (batch_size, timestep, dim) for question pooling
        question_len:   Variable lengths for question length
        cell:           rnn cell of type RNN_Cell.
        params:         Appropriate weight matrices for attention pooling computation

    Returns:
        softmax logits for the answer pointer of the beginning and the end of the answer span
    '''
    with tf.variable_scope(scope):
        weights_q, weights_p = params
        shapes = passage.get_shape().as_list()
        initial_state = question_pooling(question, units = Params.attn_size, weights = weights_q, memory_len = question_len, scope = "question_pooling")
        inputs = [passage, initial_state]
        p1_logits = attention(inputs, Params.attn_size, weights_p, memory_len = passage_len, scope = "attention")
        scores = tf.expand_dims(p1_logits, -1)
        attention_pool = tf.reduce_sum(scores * passage,1)
        _, state = cell(attention_pool, initial_state)
        inputs = [passage, state]
        p2_logits = attention(inputs, Params.attn_size, weights_p, memory_len = passage_len, scope = "attention", reuse = True)
        return tf.stack((p1_logits,p2_logits),1)
def pointer_net ( passage , passage_len , question , question_len , cell , params , scope = "pointer_network" ) : with tf . variable_scope ( scope ) : weights_q , weights_p = params shapes = passage . get_shape ( ) . as_list ( ) initial_state = question_pooling ( question , units = Params . attn_size , weights = weights_q , memory_len = question_len , scope = "question_pooling" ) inputs = [ passage , initial_state ] p1_logits = attention ( inputs , Params . attn_size , weights_p , memory_len = passage_len , scope = "attention" ) scores = tf . expand_dims ( p1_logits , - 1 ) attention_pool = tf . reduce_sum ( scores * passage , 1 ) _ , state = cell ( attention_pool , initial_state ) inputs = [ passage , state ] p2_logits = attention ( inputs , Params . attn_size , weights_p , memory_len = passage_len , scope = "attention" , reuse = True ) return tf . stack ( ( p1_logits , p2_logits ) , 1 )