LSTM Input Size Problem

3 vues (au cours des 30 derniers jours)
Agusti Padros
Agusti Padros le 23 Avr 2021
Modifié(e) : Agusti Padros le 24 Avr 2021
Hello,
I am attempting to train a LSTM network, but I'm struggling to resize the input data to the requirements of the LSTM.
· LSTM Requirements: Nx1 - where N is the number of observations
· My current data: XTrain, a 4D array (BxHxCxR) where: (Number of bands)-by-(Number of hops)-by-(Number of channels)-by-(Number of Responses)
I want to create a column vector (Nx1), where each element of the vector has a 3D array (BxHxC) inside.
My current code for resizing the data is the following:
numResponses = size(xTrain,4); % Number of training samples
for i = 1:numResponses
xTrainReshaped(:,i) = xTrain(:,:,:,i); % EACH AUDIO has size of 128x42x2channels
end
yTrain = categorical(yTrain); % CATEGORICAL, N x 1 size
ERROR: Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is
128-by-42-by-2.
What am I missing here? Some help would be certainly appreciated.
Thanks lads

Réponse acceptée

Agusti Padros
Agusti Padros le 24 Avr 2021
Hello,
I was able to solve the issue. For anyone wondering, here's the code I created:
%% RESHAPE INPUT DATA
% TRAIN DATA - MUST BE CHANGED TO: Nx1 - Where n is nTrainSamples
for i = 1:nTrainSamples
sampleTrain=xTrain(:,:,:,i);
xTrainReshaped{i} = sampleTrain;
end
xTrainReshaped = reshape(xTrainReshaped,[nTrainSamples 1]); % Create a column vector
yTrain = categorical(yTrain);
% CONVERT TEST DATA INTO Nx1
nTestSamples = size(xTest,4);
for i = 1:nTestSamples
sampleTest=xTest(:,:,:,i);
xTestReshaped{i} = sampleTest;
end
xTestReshaped = reshape(xTestReshaped,[nTestSamples 1]); % Create a column vector
yTest = categorical(yTest);

Plus de réponses (0)

Catégories

En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by