Adding new test dataset to Neural Network
6 ビュー (過去 30 日間)
古いコメントを表示
I want to add a seperate test dataset into the Pattern recognition neural network. I have following datasets:
- input - 911*9 matrix with varius detailed information
- target - 911*2 matrix with two values either 1 or 0. 1 represents group A and 0 group B.
- test - 188*9 matrix with test data. We not know to which group it belongs.
Here is my code below but it doesn't work since the t or target values is 2*911 matrix and my y (where I'm adding my testing data) is 2*188 and the function e = gsubtract(t,y) always displayes the same error:
Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.
Error in gsubtract (line 22)
c = bsxfun(@minus,a,b);
Can you please help me to add the test dataset into the neural network? Thank you!!
Here is my code (with errors...):
% This script assumes these variables are defined:
% inputs - input data, size = [9,911]
% target - target data, size = [2,911] filled with 1 and 0. 1 is group A and 0 is group B.
x = inputs';
t = target';
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
trainFcn = 'trainlm'; % Scaled conjugate gradient backpropagation.
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);
% 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'};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivide
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 30/100;
net.divideParam.testRatio = 0;
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = 'crossentropy'; % Cross-Entropy
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotconfusion', 'plotroc'};
% Train the Network
[net,tr] = train(net,x,t);
% Test the Network
y = net(test');
e = gsubtract(t,y);
performance = perform(net,t,y)
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
% Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
% View the Network
view(net)
Thank you!
0 件のコメント
採用された回答
Greg Heath
2015 年 4 月 22 日
If you have test data inputs but do not know the corresponding correct outputs, the best you can do is estimate the output.
Without knowing the correct output you cannot calculate a figure of merit.
Hope this helps.
Thank you for formally accepting my answer
Greg
2 件のコメント
Greg Heath
2015 年 4 月 23 日
Yes. However, without the corresponding target, you cannot calculate a figure of merit like mse.
その他の回答 (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!