def get_column_hidden_vectors(self): #vector representations for the column names self.column_hidden_vectors = tf.reduce_sum( nn_utils.get_embedding(self.batch_number_column_names, self.utility, self.params), 2) self.word_column_hidden_vectors = tf.reduce_sum( nn_utils.get_embedding(self.batch_word_column_names, self.utility, self.params), 2)
def get_column_hidden_vectors(self): #vector representations for the column names self.column_hidden_vectors = tf.reduce_sum( nn_utils.get_embedding(self.batch_number_column_names, self.utility, self.params), 2) self.word_column_hidden_vectors = tf.reduce_sum( nn_utils.get_embedding(self.batch_word_column_names, self.utility, self.params), 2)
def LSTM_question_embedding(self, sentence, sentence_length): #LSTM processes the input question lstm_params = "question_lstm" hidden_vectors = [] sentence = self.batch_question question_hidden = tf.zeros( [self.batch_size, self.utility.FLAGS.embedding_dims], self.data_type) question_c_hidden = tf.zeros( [self.batch_size, self.utility.FLAGS.embedding_dims], self.data_type) if (self.utility.FLAGS.rnn_dropout > 0.0): if (self.mode == "train"): rnn_dropout_mask = tf.cast( tf.random_uniform( tf.shape(question_hidden), minval=0.0, maxval=1.0) < self.utility.FLAGS.rnn_dropout, self.data_type) / self.utility.FLAGS.rnn_dropout else: rnn_dropout_mask = tf.ones_like(question_hidden) for question_iterator in range(self.question_length): curr_word = sentence[:, question_iterator] question_vector = nn_utils.apply_dropout( nn_utils.get_embedding(curr_word, self.utility, self.params), self.utility.FLAGS.dropout, self.mode) question_hidden, question_c_hidden = nn_utils.LSTMCell( question_vector, question_hidden, question_c_hidden, lstm_params, self.params) if (self.utility.FLAGS.rnn_dropout > 0.0): question_hidden = question_hidden * rnn_dropout_mask hidden_vectors.append(tf.expand_dims(question_hidden, 0)) hidden_vectors = tf.concat(axis=0, values=hidden_vectors) return question_hidden, hidden_vectors
def LSTM_question_embedding(self, sentence, sentence_length): #LSTM processes the input question lstm_params = "question_lstm" hidden_vectors = [] sentence = self.batch_question question_hidden = tf.zeros( [self.batch_size, self.utility.FLAGS.embedding_dims], self.data_type) question_c_hidden = tf.zeros( [self.batch_size, self.utility.FLAGS.embedding_dims], self.data_type) if (self.utility.FLAGS.rnn_dropout > 0.0): if (self.mode == "train"): rnn_dropout_mask = tf.cast( tf.random_uniform( tf.shape(question_hidden), minval=0.0, maxval=1.0) < self.utility.FLAGS.rnn_dropout, self.data_type) / self.utility.FLAGS.rnn_dropout else: rnn_dropout_mask = tf.ones_like(question_hidden) for question_iterator in range(self.question_length): curr_word = sentence[:, question_iterator] question_vector = nn_utils.apply_dropout( nn_utils.get_embedding(curr_word, self.utility, self.params), self.utility.FLAGS.dropout, self.mode) question_hidden, question_c_hidden = nn_utils.LSTMCell( question_vector, question_hidden, question_c_hidden, lstm_params, self.params) if (self.utility.FLAGS.rnn_dropout > 0.0): question_hidden = question_hidden * rnn_dropout_mask hidden_vectors.append(tf.expand_dims(question_hidden, 0)) hidden_vectors = tf.concat(axis=0, values=hidden_vectors) return question_hidden, hidden_vectors
def get_column_hidden_vectors(self): #vector representations for the column names number_column_lengths = tf.reshape( self.batch_number_column_name_lengths, [self.batch_size, self.num_cols, 1]) word_column_lengths = tf.reshape( self.batch_word_column_name_lengths, [self.batch_size, self.num_word_cols, 1]) number_column_embeddings = nn_utils.get_embedding( self.batch_number_column_names, self.utility, self.params, self.batch_number_column_name_mask) word_column_embeddings = nn_utils.get_embedding( self.batch_word_column_names, self.utility, self.params, self.batch_word_column_name_mask) number_column_description_lengths = tf.reshape( self.batch_number_column_description_lengths, [self.batch_size, self.num_cols, 1]) word_column_description_lengths = tf.reshape( self.batch_word_column_description_lengths, [self.batch_size, self.num_word_cols, 1]) number_column_description_embeddings = nn_utils.get_embedding( self.batch_number_column_descriptions, self.utility, self.params, self.batch_number_column_description_mask) word_column_description_embeddings = nn_utils.get_embedding( self.batch_word_column_descriptions, self.utility, self.params, self.batch_word_column_description_mask) number_column_sum = tf.reduce_sum(number_column_embeddings, 2) word_column_sum = tf.reduce_sum(word_column_embeddings, 2) number_column_description_sum = tf.reduce_sum( number_column_description_embeddings, 2) word_column_description_sum = tf.reduce_sum( word_column_description_embeddings, 2) self.column_hidden_vectors = tf.divide( number_column_sum, number_column_lengths) + tf.divide( number_column_description_sum, number_column_description_lengths) self.word_column_hidden_vectors = tf.divide( word_column_sum, word_column_lengths) + tf.divide( word_column_description_sum, word_column_description_lengths)
def create_summary_embeddings(self): #embeddings for each text entry in the table using parameters of the question module self.summary_text_entry_embeddings = tf.reduce_sum( tf.expand_dims(self.batch_exact_match, 3) * tf.expand_dims( tf.expand_dims( tf.expand_dims( nn_utils.get_embedding( self.utility.entry_match_token_id, self.utility, self.params), 0), 1), 2), 2)
def create_summary_embeddings(self): #embeddings for each text entry in the table using parameters of the question module self.summary_text_entry_embeddings = tf.reduce_sum( tf.expand_dims(self.batch_exact_match, 3) * tf.expand_dims( tf.expand_dims( tf.expand_dims( nn_utils.get_embedding(self.utility.entry_match_token_id, self.utility, self.params), 0), 1), 2), 2)