Long Short Term Memory

2 次查看(过去 30 天)
Dear all, I am trying to implement a LSTM, for sequence-to-label classification duty. Since I know all the sequence, I am using BILSTM. My training dataset is composed by 12000 observations, of lenght 2048, with 2 features. Such dataset is stored in a cell array, having dimension 12000x1, where each cell is 2x2048, and binary label (0 or 1) in a categorigal array. The architecture used for this aim is the follow:
inputSize = 2;
numHiddenUnits1 = 200;
numHiddenUnits2 = 150;
numClasses = 2;
layers = [ ...
sequenceInputLayer(inputSize)
bilstmLayer(numHiddenUnits1,'OutputMode','sequence')
bilstmLayer(numHiddenUnits2,'OutputMode','last')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
maxEpochs = 30;
miniBatchSize = 25;
options2 = [...
trainingOptions('adam', ...
'ExecutionEnvironment','gpu', ...
'GradientThreshold',1, ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'SequenceLength','longest', ...
'Shuffle','never', ...
'Verbose',1, ...
'Plots','training-progress',...
'CheckpointPath','C:\Users\jwb15214\Desktop\CNN_MATLABtool\CV-CNN monodimensional signal\CV-CNN-master\CV-CNN\CheckPointsPath');
net5 = trainNetwork(train_data_cell,categorical_label_new,layers,options2);
The way how LSTM is explained on the Matlab help, let me understand that each LSTM unit is connected to a sample of the input sequence. In my case, I choose to set the first LSTMLayer a number of hidden layer equal to 200, but with a sequence length of 2048. How Does it work in this case? Is there any documentation explaing the correlation between input and output of a bilstm? What is the difference between the 'sequence' mode and the 'last' mode in terms of filter size and features map?
Kind regards Alessio

采纳的回答

Vishal Bhutani
Vishal Bhutani 2018-9-21
By my understanding you want some detail information related to LSTM. For more detail information related to LSTM, you can find it in the attached documentation link attached:
I think the above links will resolve your first two questions. To create an LSTM network for sequence-to-label classification, create a layer array containing a sequence input layer, an LSTM layer, a fully connected layer, a softmax layer, and a classification output layer. Specify the size of the sequence input layer to be the number of features of the input data. Specify the size of the fully connected layer to be the number of classes. You do not need to specify the sequence length. For the LSTM layer, specify the number of hidden units and the output mode 'last'. To create an LSTM network for sequence-to-sequence classification, use the same architecture for sequence-to-label classification, but set the output mode of the LSTM layer to 'sequence'. Here is the documentation link:
  1 个评论
Alessio Izzo
Alessio Izzo 2018-9-21
Hi Vishal, thanks a lot for your reply. I have got this. As you can see from the code above, I was using a deeper LSTM architecture, since I saw better result than a single bilstm layer. The point is, How the input x_t is processed through the network? Let's consider the input x_t be a single observation of my sequence, having 2 features with length of 2048 (so a size of 2x2048), and LSTM architecture as shown in the piece of code above. From the documentation, it looks like every LSTM unit of the first bilstm layer will have as input a single sample per feature of x_t. Is it right? And how it works since the number of hidden units is less than the sequence length?

请先登录,再进行评论。

更多回答(1 个)

Sanjana Sankar
Sanjana Sankar 2019-7-17
Hi. I am working on buiding a BiLSTM model too. I do not undestand how to feed the network from the documentations given in MATLAB. Can someone please tell me how I should input the sequence to the input layer?
Thanks in advance!

类别

Help CenterFile Exchange 中查找有关 Build Deep Neural Networks 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by