问题描述
LSTM可以很好地预测序列后会发生什么,但是我假设我们有很多序列,并且每个序列都对应一个类标签.
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.
我们如何使用LSTM对这些序列进行分类?
How can we use LSTM to classify these sequences?
推荐答案
LSTM可用于预测以及分类任务.
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.
作为LSTM的输出(在这里我用time_major == False来解释dynamic_rnn),我们有一个张量,其形状为 output = [batch_size,sequnce_length,cell.output_size] ,这意味着对于批处理中的每一行,我们都有[sequnce_length,cell.output_size].
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.方法1
1. Method 1
1.方法2
1. Method 2
希望这会有所帮助.
这篇关于我们如何使用LSTM对序列进行分类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!