My dataset consists of 322 samples in four categories, with the last column being labeled，Please help me take a look at my code and why the accuracy is very low？
3 次查看（过去 30 天）
sz = size(dataset);
dataset = dataset(randperm(sz(1)),:);
classes = unique(trainlabel)
numClasses = numel(unique(trainlabel))
PD = 0.8 ;
Ptrain = ; Ttrain = ;
Ptest = ; Ttest = ;
for i = 1 : length(classes)
indi = find(trainlabel==classes(i));
indi = indi(randperm(length(indi)));
indj = round(length(indi)*PD);
Ptrain = [Ptrain; traindata(indi(1:indj),:)]; Ttrain = [Ttrain; trainlabel(indi(1:indj),:)];
Ptest = [Ptest; traindata(indi(1+indj:end),:)]; Ttest = [Ttest; trainlabel(indi(1+indj:end),:)];
layers = [imageInputLayer([7 1 1])%输入层
maxPooling2dLayer(2,'Stride',2,'Padding',[0 0 0 1])%池化层
options = trainingOptions('adam', ...
'ExecutionEnvironment', 'cpu', ...
net = trainNetwork(Ptrain,Ttrain,layers,options);
As per the dataset/information provided, there are only 322 samples collectively for all the classes.
The dataset size seems to be quite small to get a good accuracy from a NN. I see that the number of epochs is set to 5000, but the primary reason for low accuracy seems the small dataset size.
It is suggested to get more data samples, there is no upper limit but training with 5000 data samples should show better accuracy.
Also, try maintaining a balanced dataset (equivalent size of data of each class).