I'm trying to classify videos using LSTM but getting a different output, can anyone tell me what I'm doing wrong?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!