I am trying to build a bidirectional RNN with attention mechanism for sequence classification. I am having some issues understanding the helper function. I have seen that the one used for training needs the decoder inputs, but as I want a single label from the whole sequence, I don't know exactly what input should I give here. This is the structure that I have built so far:
# Encoder LSTM cells
lstm_fw_cell = rnn.BasicLSTMCell(n_hidden)
lstm_bw_cell = rnn.BasicLSTMCell(n_hidden)
# Bidirectional RNN
outputs, states = tf.nn.bidirectional_dynamic_rnn(lstm_fw_cell,
lstm_bw_cell, inputs=x,
sequence_length=seq_len, dtype=tf.float32)
# Concatenate forward and backward outputs
encoder_outputs = tf.concat(outputs,2)
# Decoder LSTM cell
decoder_cell = rnn.BasicLSTMCell(n_hidden)
# Attention mechanism
attention_mechanism = tf.contrib.seq2seq.LuongAttention(n_hidden, encoder_outputs)
attn_cell = tf.contrib.seq2seq.AttentionWrapper(decoder_cell,
attention_mechanism, attention_size=n_hidden)
name="attention_init")
# Initial attention
attn_zero = attn_cell.zero_state(batch_size=tf.shape(x)[0], dtype=tf.float32)
init_state = attn_zero.clone(cell_state=states[0])
# Helper function
helper = tf.contrib.seq2seq.TrainingHelper(inputs = ???)
# Decoding
my_decoder = tf.contrib.seq2seq.BasicDecoder(cell=attn_cell,
helper=helper,
initial_state=init_state)
decoder_outputs, decoder_states = tf.contrib.seq2seq.dynamic_decode(my_decoder)
My input is a sequence [batch_size,sequence_length,n_features] and my output is a single vector with N possible classes [batch_size,n_classes].
Do you know what am I missing here or if it is possible to use seq2seq for sequence classification?