(attn_size,initializer = tf.truncated_normal_initializer)
Args:
        attn_size: the size of attention specified in https://www.microsoft.com/en-us/research/wp-content/uploads/2017/05/r-net.pdf
        initializer: the author of the original paper used gaussian initialization however I found xavier converge faster

    Returns:
        params: A collection of parameters used throughout the layers
Args:
        attn_size: the size of attention specified in https://www.microsoft.com/en-us/research/wp-content/uploads/2017/05/r-net.pdf
        initializer: the author of the original paper used gaussian initialization however I found xavier converge faster
Args : attn_size : the size of attention specified in https : // www . microsoft . com / en - us / research / wp - content / uploads / 2017 / 05 / r - net . pdf initializer : the author of the original paper used gaussian initialization however I found xavier converge faster
def get_attn_params(attn_size,initializer = tf.truncated_normal_initializer):
    '''
    Args:
        attn_size: the size of attention specified in https://www.microsoft.com/en-us/research/wp-content/uploads/2017/05/r-net.pdf
        initializer: the author of the original paper used gaussian initialization however I found xavier converge faster

    Returns:
        params: A collection of parameters used throughout the layers
    '''
    with tf.variable_scope("attention_weights"):
        params = {"W_u_Q":tf.get_variable("W_u_Q",dtype = tf.float32, shape = (2 * attn_size, attn_size), initializer = initializer()),
                #"W_ru_Q":tf.get_variable("W_ru_Q",dtype = tf.float32, shape = (2 * attn_size, 2 * attn_size), initializer = initializer()),
                "W_u_P":tf.get_variable("W_u_P",dtype = tf.float32, shape = (2 * attn_size, attn_size), initializer = initializer()),
                "W_v_P":tf.get_variable("W_v_P",dtype = tf.float32, shape = (attn_size, attn_size), initializer = initializer()),
                "W_v_P_2":tf.get_variable("W_v_P_2",dtype = tf.float32, shape = (2 * attn_size, attn_size), initializer = initializer()),
                "W_g":tf.get_variable("W_g",dtype = tf.float32, shape = (4 * attn_size, 4 * attn_size), initializer = initializer()),
                "W_h_P":tf.get_variable("W_h_P",dtype = tf.float32, shape = (2 * attn_size, attn_size), initializer = initializer()),
                "W_v_Phat":tf.get_variable("W_v_Phat",dtype = tf.float32, shape = (2 * attn_size, attn_size), initializer = initializer()),
                "W_h_a":tf.get_variable("W_h_a",dtype = tf.float32, shape = (2 * attn_size, attn_size), initializer = initializer()),
                "W_v_Q":tf.get_variable("W_v_Q",dtype = tf.float32, shape = (attn_size,  attn_size), initializer = initializer()),
                "v":tf.get_variable("v",dtype = tf.float32, shape = (attn_size), initializer =initializer())}
        return params
def get_attn_params ( attn_size , initializer = tf . truncated_normal_initializer ) : with tf . variable_scope ( "attention_weights" ) : params = { "W_u_Q" : tf . get_variable ( "W_u_Q" , dtype = tf . float32 , shape = ( 2 * attn_size , attn_size ) , initializer = initializer ( ) ) , #"W_ru_Q":tf.get_variable("W_ru_Q",dtype = tf.float32, shape = (2 * attn_size, 2 * attn_size), initializer = initializer()), "W_u_P" : tf . get_variable ( "W_u_P" , dtype = tf . float32 , shape = ( 2 * attn_size , attn_size ) , initializer = initializer ( ) ) , "W_v_P" : tf . get_variable ( "W_v_P" , dtype = tf . float32 , shape = ( attn_size , attn_size ) , initializer = initializer ( ) ) , "W_v_P_2" : tf . get_variable ( "W_v_P_2" , dtype = tf . float32 , shape = ( 2 * attn_size , attn_size ) , initializer = initializer ( ) ) , "W_g" : tf . get_variable ( "W_g" , dtype = tf . float32 , shape = ( 4 * attn_size , 4 * attn_size ) , initializer = initializer ( ) ) , "W_h_P" : tf . get_variable ( "W_h_P" , dtype = tf . float32 , shape = ( 2 * attn_size , attn_size ) , initializer = initializer ( ) ) , "W_v_Phat" : tf . get_variable ( "W_v_Phat" , dtype = tf . float32 , shape = ( 2 * attn_size , attn_size ) , initializer = initializer ( ) ) , "W_h_a" : tf . get_variable ( "W_h_a" , dtype = tf . float32 , shape = ( 2 * attn_size , attn_size ) , initializer = initializer ( ) ) , "W_v_Q" : tf . get_variable ( "W_v_Q" , dtype = tf . float32 , shape = ( attn_size , attn_size ) , initializer = initializer ( ) ) , "v" : tf . get_variable ( "v" , dtype = tf . float32 , shape = ( attn_size ) , initializer = initializer ( ) ) } return params