这是神经网络模式识别。我使用了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 :(得分:0)
您的hiddenLayerSize为1非常小。这只允许对线性可分的数据进行分类(即绘制时可以轻松在两个类之间画线的数据。)
尝试使用10的hiddenLayerSize并根据需要上升以获得更好的结果。最好从小做起,看看是否可以使用简单的解决方案。使用54149可能需要更高,但这取决于问题的复杂性。
当您训练数据时,将分为训练,验证和测试集。培训将自动停止泛化,验证数据已达到顶峰。测试数据的准确性(不用于训练或停止)将很好地衡量网络可以推广到类似新数据的程度。