2012-05-23 4 views
3

마우스 제스처 인식 (입력은 각도 임)을위한 간단한 신경 네트워크를 만들었고 nprtool (생성을위한 function patternnet)을 사용했습니다. I는 네트워크의 가중치와 바이어스 저장된 :MATLAB 신경망 패턴 인식

W1=net.IW{1,1}; 
W2=net.LW{2,1}; 
b1=net.b{1,1}; 
b2=net.b{2,1}; 

in가 입력되고, 여기서 계산 결과는 I tansig(W2*(tansig(W1*in+b1))+b2); 사용. 그러나 결과는 끔찍합니다 (각 숫자는 대략 0.99입니다). 추천 번호 net(in)의 출력이 좋습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까 ? 첫 번째 방법이 나쁘다는 것이 나에게 매우 중요합니다 (C++ 프로그램에서도 마찬가지입니다). 나는 도움을 청하고있다.

[편집] 아래에 코드가 nprtool GUI에서 발생했다. 어쩌면 누군가 도움이 될 수도 있지만이 코드에서 내 문제에 대한 해결책을 찾지 못합니다. 숨겨진 출력 레이어와 뉴런 출력에는 tansig 활성화 함수가 사용됩니다 (MATLAB 네트워크에는 매개 변수가 있습니까?). processFcns를 정의하는 라인을 찾습니다 - 코드에서 볼 수 있듯이

% Solve a Pattern Recognition Problem with a Neural Network 
% Script generated by NPRTOOL 
% Created Tue May 22 22:05:57 CEST 2012 
% 
% This script assumes these variables are defined: 
% 
% input - input data. 
% target - target data.  
inputs = input; 
targets = target; 

% 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.inputs{1}.processFcns = {'removeconstantrows','mapminmax'}; 
net.outputs{2}.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 = 15/100; 
net.divideParam.testRatio = 15/100; 

% For help on training function 'trainlm' type: help trainlm 
% For a list of all training functions type: help nntrain 
net.trainFcn = 'trainlm'; % Levenberg-Marquardt 

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

% 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) 

% 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) 
+1

net', 우리는 매개 변수를 사용했던 것을 추측 할 수없는'생성 된 코드를 기입하십시오. 어떤 함수가 그것을 만들었는지 추측 할 필요가 없다는 것도 좋은 일일 것입니다. (네트워크) –

+0

1 분 전에 이것을했습니다. 나는 도움에 대해 매우 감사 할 것입니다. – mydew

답변

4

, 네트워크는 대상의 입력 및 후 처리의 전처리를 자동으로 적용합니다. 이것은 훈련 된 파라미터가 전처리 된 입력에 대해 유효하고 네트워크의 출력이 후 처리된다는 것을 의미합니다 (타겟과 동일한 매개 변수로). 따라서 귀하의 전화 번호 tansig(W2*(tansig(W1*in+b1))+b2);에서는 원래 입력을 사용할 수 없습니다. 입력을 전처리하고 결과를 네트워크의 입력으로 사용하고 대상을 후 처리하는 데 사용 된 것과 동일한 매개 변수를 사용하여 출력을 후 처리해야합니다. 그래야만 net(in)으로 전화하는 것과 같은 결과를 얻을 수 있습니다.

여기에서 자세한 내용을보실 수 있습니다 : http://www.mathworks.com/help/toolbox/nnet/rn/f0-81221.html#f0-81692

+0

아, 이제 알겠습니다. 고마워요! :) – mydew