How can I test a trained Neural Network Model on new test data?
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to test a trined NN model in MATLAB but it's giving the wrong output. I have trained the model on input of order 223x448 with labels as 223x1. And tested on the another set of order 114x448. where 114 comprises of two classes,each of the 57 labels for class 1 and clas 2. When i test the model it classify each class as one class; class 1 or class 2; and gives the confusion matrix of [57 57 ; 0 0]. Can anyone please help where i am doing this wrong.
The code to train the model:
trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation.
hiddenLayerSize = [10 10 10];
net = patternnet(hiddenLayerSize, trainFcn);
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.performFcn = 'crossentropy'; % Cross-Entropy
net.plotFcns = {'plotconfusion'};
[net,tr] = train(net,train_f,train_L);
ANd this is how i test:
y = net(test_f);
e = gsubtract(test_L,y);
performance = perform(net,test_L,y);
tind = vec2ind(test_L);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
% Testing accuracy
[values,pred_ind]=max(y,[],1);
[~,actual_ind]=max(test_L,[],1);
accuracy=sum(pred_ind==actual_ind)/size(test_f,2)*100
fprintf('\n Classification Accuracy (NN): %g %%',accuracy);
[~,con]=confusion((test_L),y);
figure, plotconfusion(test_L,y)
Any help will be highly appreciated.
1 个评论
Srivardhan Gadila
2020-3-11
In 223 training samples what is the count w.r.t class 1 and class 2?
Also can you check the confusion matrix on the training set after training the network?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!