2012-01-12 13 views
2

신경망 matlab을 만들었습니다.Matlab에서 신경망을 계산하는 수식

 

    load dati.mat; 
    inputs=dati(:,1:8)'; 
    targets=dati(:,9)'; 
    hiddenLayerSize = 10; 
    net = patternnet(hiddenLayerSize); 
    net.inputs{1}.processFcns = {'removeconstantrows','mapminmax', 'mapstd','processpca'}; 
    net.outputs{2}.processFcns = {'removeconstantrows','mapminmax', 'mapstd','processpca'}; 

    net = struct(net); 
    net.inputs{1}.processParams{2}.ymin = 0; 
    net.inputs{1}.processParams{4}.maxfrac = 0.02; 
    net.outputs{2}.processParams{4}.maxfrac = 0.02; 
    net.outputs{2}.processParams{2}.ymin = 0; 
    net = network(net); 

    net.divideFcn = 'divideind'; 
    net.divideMode = 'sample'; % Divide up every sample 
    net.divideParam.trainInd = 1:428; 
    net.divideParam.valInd = 429:520; 
    net.divideParam.testInd = 521:612; 
    net.trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation 
    net.performFcn = 'mse'; % Mean squared error 
    net.plotFcns = {'plotperform','plottrainstate','ploterrhist', 'plotregression', 'plotconfusion', 'plotroc'}; 
    net=init(net); 
    net.trainParam.max_fail=20; 

    [net,tr] = train(net,inputs,targets); 

    outputs = net(inputs); 
    errors = gsubtract(targets,outputs); 
    performance = perform(net,targets,outputs) 

지금 내가 네트워크의 무게와 편견을 저장하고 수식을 작성하려는 :이 스크립트입니다. 나는 무게와 편견 저장 한 : 그래서

 

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

을, 나는 데이터 전처리를 한 적이 그리고 난 다음 식

 

    max_range=0; 
    [y,ps]=removeconstantrows(input, max_range); 

    ymin=0; 
    ymax=1; 
    [y,ps2]=mapminmax(y,ymin,ymax); 

    ymean=0; 
    ystd=1; 
    y=mapstd(x,ymean,ystd); 

    maxfrac=0.02; 
    y=processpca(y,maxfrac); 

    in=y'; 

    uscita=tansig(W2*(tansig(W1*in+b1))+b2); 

을 썼다 그러나 동일한 입력 입력이 = [1 : 8] 나는 다른 결과를 얻는다. 왜? 뭐가 문제 야? 도와주세요! 그것은 중요합니다!

나는 matlab에 R2010B

답변

0

그것은 당신이 같은 입력을 사전 처리하지만 출력을 후 처리하지 보이는 사용합니다. 후 처리는 "역"처리 양식을 사용합니다. (대상은 사전 처리되므로 출력은 역 처리됩니다.)

-1

이 방정식

uscita=tansig(W2*(tansig(W1*in+b1))+b2); 

은 잘못된 것입니다. 왜 두 개의 tansig을 쓰나요? 10 번 던지기를 10 번이나 쓰거나 i=1:10을 사용하십시오.