필터 지우기
필터 지우기

Run/Display Neural Network on Test data after training

조회 수: 9 (최근 30일)
Montgomery
Montgomery 2014년 5월 8일
답변: Greg Heath 2014년 5월 9일
Hi all, I have a pipeline where I test/train some data on a neural network, the code was generated using the neural network toolbox so it should be fairly standard for those of you who have used this before.
The problem is I want to run my neural network on some fresh test data now that it is has been trained.
results = net(X');
view(results);
Error using view>ViewCore (line 171)
Argument must be scalar, or two-vector
Error in view (line 69)
ViewCore(hAxes, viewArgs{:});
Error in mainNeural2 (line 95)
view(results)
Error in mainNeural (line 139)
mainNeural2
I'm wondering if you have any advice on how I can actually display my neural network, I've looked at "results" and the values returned seem to be the same dimensions and roughly in keeping with the initial training/test run.
Just so you know the 'net' used in the code above is returned from a separate function beforehand so it is in the workspace.
The data in results looks like this:
0.500013823172753 0.500001510152403 ........
0.579181096664039 0.654171440064530 .......
0.521562315394349 0.502021472887101
0.538257766843839 0.521015241194003
0.513800680860541 0.503471901344177
0.847184317064479 0.819318434357785
As you can see this is meaningless to me without a graphical representation. Thanks in advance for your help, I'm really stuck and it's much appreciated.
Edit: I can only thing this has something to do with the settings set during the test/training run. For example
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.output.processFcns = {'removeconstantrows','mapminmax'};
My ideal end would be to display a confusion matrix, in the short term I just want to see what class it classifies the values as so I can see by eye on a small dataset if it is working. Cheers!

채택된 답변

Greg Heath
Greg Heath 2014년 5월 9일
The command view(net) just yields a picture of the net.
If you want to view results either print them out or plot them.
If you want class predictions and error rates, you have to calculate them. See some of my classification posts. Search on
greg patternet
The standard c-class classifier is trained with targets that are columns of the unit matrix eye(c). Outputs can be obtained from net(input) or sim(net,input). Vector targets, outputs and classindices are related by vec2ind and ind2vec.
Also, if you just type patternnet with no ending semicolon you will see the names of plot functions that can be used.
You really didn't give enough info. What type of net? What type of output transfer function? Input dimensionality? How many classes? etc
Hope this helps.
Thank you for formally accepting my answer
Greg

추가 답변 (2개)

Scott
Scott 2014년 5월 9일
After you have built and trained your network, use the "sim" command to simulate the network, e.g.
Y = sim(net,P) % P is some input data

Montgomery
Montgomery 2014년 5월 9일
results = net(X'); does the same thing, both give the same results. Thanks for offering a solution though, any more ideas?

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by