sent1_mask = tf.cast(tf.sign(sentence1), dtype=tf.float32) sent2_mask = tf.cast(tf.sign(sentence2), dtype=tf.float32) sent1_len = tf.reduce_sum(sent1_mask, -1) sent2_len = tf.reduce_sum(sent2_mask, -1) antonym1 = tf.expand_dims(mnli.antonym1, -1) antonym2 = tf.expand_dims(mnli.antonym2, -1) exact1to2 = tf.expand_dims(mnli.exact1to2, -1) exact2to1 = tf.expand_dims(mnli.exact2to1, -1) synonym1 = tf.expand_dims(mnli.synonym1, -1) synonym2 = tf.expand_dims(mnli.synonym2, -1) sent1char = mnli.sent1char sent2char = mnli.sent2char with tf.variable_scope("word_embedding"): glove_embedding = embedded(mnli.embedding) embedding_pre = glove_embedding(sentence1) embedding_hyp = glove_embedding(sentence2) with tf.variable_scope("char_embedding"): char_embedding = embedded(mnli.char_embedding, name="char") char_embedding_pre = char_embedding(sent1char) char_embedding_hyp = char_embedding(sent2char) with tf.variable_scope("conv") as scope: conv_pre = char_conv(char_embedding_pre, filter_size=filter_size) scope.reuse_variables() conv_hyp = char_conv(char_embedding_hyp, filter_size=filter_size) embed_pre = tf.concat((embedding_pre, antonym1, exact1to2, synonym1, conv_pre), -1)
sent1_mask = tf.cast(tf.sign(sentence1), dtype=tf.float32) sent2_mask = tf.cast(tf.sign(sentence2), dtype=tf.float32) sent1_len = tf.reduce_sum(sent1_mask, -1) sent2_len = tf.reduce_sum(sent2_mask, -1) antonym1 = tf.expand_dims(mnli.antonym1, -1) antonym2 = tf.expand_dims(mnli.antonym2, -1) exact1to2 = tf.expand_dims(mnli.exact1to2, -1) exact2to1 = tf.expand_dims(mnli.exact2to1, -1) synonym1 = tf.expand_dims(mnli.synonym1, -1) synonym2 = tf.expand_dims(mnli.synonym2, -1) sent1char = mnli.sent1char sent2char = mnli.sent2char with tf.variable_scope("word_embedding"): glove_embedding = embedded(mnli.embedding) embedding_pre = glove_embedding(sentence1) embedding_hyp = glove_embedding(sentence2) # with tf.variable_scope("char_embedding"): # char_embedding = embedded(mnli.char_embedding, name="char") # char_embedding_pre = char_embedding(sent1char) # char_embedding_hyp = char_embedding(sent2char) # with tf.variable_scope("conv") as scope: # conv_pre = char_conv(char_embedding_pre) # scope.reuse_variables() # conv_hyp = char_conv(char_embedding_hyp) # embed_pre = tf.concat((embedding_pre, antonym1, exact1to2, synonym1, conv_pre), -1) # embed_hyp = tf.concat((embedding_hyp, antonym2, exact2to1, synonym2, conv_hyp), -1)