I'm trying to classify videos using LSTM but getting a different output, can anyone tell me what I'm doing wrong?
1 view (last 30 days)
Show older comments
To train-:
if true
rootFolder = 'C:\New folder\Project\Action_Data\1\';
categories = {'jump','walk','run'};
imds = imageDatastore(fullfile(rootFolder, categories), 'LabelSource', 'foldernames');
tbl = countEachLabel(imds);
k=1;
for loop = 1:3
i = tbl{loop,2};
for lo = 1:i
img = readimage(imds,lo);
img = rgb2gray(img);
m{k} = img;
cate = tbl{loop,1};
a(k) = cate;
k = k+1;
end
end
m = m';
a = a';
inputSize = 144;
outputSize = 100;
outputMode = 'last';
numClasses = 3;
layers = [ ...
sequenceInputLayer(inputSize)
lstmLayer(outputSize,'OutputMode',outputMode)
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
if true
% code
end
maxEpochs = 50;
miniBatchSize = 50;
options = trainingOptions('sgdm', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize);
if true
% code
end
net = trainNetwork(m,a,layers,options);
end
And to test -:
if true
rootFolder = 'C:\New folder\Project\Action_Data\1\';
categories = {'jump'};
imds = imageDatastore(fullfile(rootFolder, categories), 'LabelSource', 'foldernames');
tbl = countEachLabel(imds);
for lo = 1:67
img = readimage(imds,lo);
img = rgb2gray(img);
n{lo} = img;
end
% n = n';
miniBatchSize = 19;
YPred = classify(net,n, ...
'MiniBatchSize',miniBatchSize);
%acc = sum(YPred == YTest)./numel(YTest);
end
But I'm not getting the right result(Expected result-Jump, Test result-Walk. can anyone tell me what I'm doing wrong? P.S I'm taking the individual frames as input.
0 Comments
Answers (0)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!