2014-03-25 33 views
0

這是神經網絡模式識別。我使用了一個vec數據集1 * 54149和1 * 54149目標,我試圖訓練我的神經網絡做二元分類(1和0)。我想要最好?如何獲得更好的神經網絡測試誤差/準確性?

clear all; 
clc; 
load vec; load target;  
inputs = double(vec);  
targets = double(target);  

% Create a Pattern Recognition Network  
hiddenLayerSize = 1;  
%net = patternnet(hiddenLayerSize);  
net = patternnet(hiddenLayerSize);  

% Choose Input and Output Pre/Post-Processing Functions  
% For a list of all processing functions type: help nnprocess  
net.inputs{1}.processFcns = {'removeconstantrows','mapstd'};  
net.outputs{2}.processFcns = {'removeconstantrows','mapstd'};  


% Setup Division of Data for Training, Validation, Testing  
% For a list of all data division functions type: help nndivide  
net.divideFcn = 'dividerand';  
net.divideMode = 'sample'; % Divide up every sample  
net.divideParam.trainRatio = 50/100;  
net.divideParam.valRatio = 25/100;  
net.divideParam.testRatio = 25/100;  

% For a list of all training functions type: help nntrain  
net.trainFcn = 'trainrp';   

% Choose a Performance Function  
% For a list of all performance functions type: help nnperformance  
net.performFcn = 'mse';   

% Choose Plot Functions  
% For a list of all plot functions type: help nnplot  
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...  
    'plotregression', 'plotfit'};  


% Train the Network  
[net,tr] = train(net,inputs,targets);  

% Test the Network  
outputs = net(inputs);  
errors = gsubtract(targets,outputs);  
performance = perform(net,targets,outputs);   
[tpr,fpr,thresholds] = roc(targets,outputs);   

% Recalculate Training, Validation and Test Performance  
trainTargets = targets .* tr.trainMask{1};  
valTargets = targets .* tr.valMask{1};  
testTargets = targets .* tr.testMask{1};  
trainPerformance = perform(net,trainTargets,outputs);  
valPerformance = perform(net,valTargets,outputs);  
testPerformance = perform(net,testTargets,outputs);   


% View the Network  
view(net)  

%Plots  
% Uncomment these lines to enable various plots.  
figure, plotperform(tr)  
figure, plottrainstate(tr)   
figure, plotconfusion(targets,outputs)  
figure, ploterrhist(errors)  
figure, plotregression(targets,outputs)  
figure, plotroc(targets,outputs)  

所以請有人能幫助我。預先感謝您

回答

0

您hiddenLayerSize爲1是非常小的。這隻允許對可線性分離的數據進行分類(即當繪製數據時,您可以輕鬆地在兩個類別之間繪製線條)。

嘗試hiddenLayerSize爲10並根據需要上升以獲得更好的結果。從小開始總是最好的,以查看是否可以實現簡單的解決方案。有了54149,你可能需要高得多,但這取決於問題的複雜性。

當你訓練的數據將被分爲訓練,驗證和測試集。培訓將自動停止推廣到驗證數據達到頂峯。測試數據(不用於訓練或停止)的準確性將很好地衡量網絡預計能夠推廣到相似的新數據的程度。