시퀀스 분류를위한주의 메커니즘을 사용하여 양방향 RNN을 작성하려고합니다. 도우미 기능을 이해하는 데 몇 가지 문제가 있습니다. 훈련에 사용 된 것은 디코더 입력이 필요하다는 것을 알았지 만 전체 시퀀스의 단일 레이블을 원하기 때문에 정확히 입력해야 할 항목을 알지 못합니다. 이것은 지금까지 구축 한 구조이다시퀀스 분류를위한주의 메커니즘 (seq2seq tensorflow r1.1)
# 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)
내 입력 [BATCH_SIZE, sequence_length, n_features] 서열이다 내 출력은 N 가능한 클래스 [BATCH_SIZE, n_classes] 단일 벡터이다.
여기에 무엇이 누락되었거나 시퀀스 분류에 seq2seq를 사용할 수 있는지 알고 계십니까?