How can I test a trained Neural Network Model on new test data?
조회 수: 1 (최근 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!