问题
LSTM is good for predicting what is going to happen after a sequence, but I assume that we have many sequences and that each sequence corresponds to a class label.
How can we use LSTM to classify these sequences?
回答1:
LSTM can be used for prediction as well as classification tasks.
For classification, you can follow most commonly used architectures that I have described below. However, you can build your own model depending on your requirement.
As the output of LSTM (Here I explain dynamic_rnn with time_major == False), we have a tensor with a shape of output = [batch_size, sequnce_length, cell.output_size], which means that for each row in the batch we have [sequnce_length, cell.output_size].
1. Method 1
1. Method 2
Hope this helps.
来源:https://stackoverflow.com/questions/46750692/how-do-we-use-lstm-to-classify-sequences