does anyone know why this neural network is not giving the right target values????plz any helpppppp
    3 ビュー (過去 30 日間)
  
       古いコメントを表示
    
%a=imread('A.bmp');
%a=imresize(a,[6,5]);
%a=imresize(a,[1,30]);
inp=[0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 0 1];
out=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
net= newff(inp,out,10)
tol = 0.001;               % Error tolerance
%net.trainParam.show = 50;
net.trainParam.lr = 0.007;
net.trainParam.epochs = 500;
net.trainParam.alpha = 0.5;
%net.trainParam.goal = 1e-5;
[net,tr]=train(net,inp,out);
a=sim(net,inp)
0 件のコメント
採用された回答
  Greg Heath
      
      
 2013 年 11 月 13 日
        % Weird data set:
 plot(input,target,'o')
The data does not represent points from reasonable function. The target says" Regardless of the input, if the output is 0, your error will only be 3.33%".
Looking at an escalation of models (H=0:9) shows that the Linear model (H=0, NN with no hidden layer) is the best with a coefficient of determination (Wikipedia/R-squared) of only 0.0264. It is only slightly better than the constant output = 0 model.
 close all, clear all, clc
 N =30
 input  = [0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 0 1]; 
 target = [ 1, zeros( 1,N-1)];
% The simplest model is the constant output model that outputs the mean of the target regardless of the input.
 y00   = (1/N)*ones(1,N); % 0.0333*ones(1,30)
 e00   = target-y00;     ; % [ 0.9667, -0.0333*ones(1,29)]
 MSE00 = mse(target-y00)       % 0.0322
% The next simplest is the linear model
 W0    =  target/[ ones(1,N) ; input ] % W0 = [ 0.0588 -0.0588 ]
 y0    =  W0 * [ ones(1,N) ; input ];  % y0 =  0.0588*(1-input)
 e0    =  target-y0;     ;             % [ 0.9412, -y0(2:end)]
 MSE0  =  mse(target-y0)               % 0.0314  Not much better than constant model
 R20   = 1 - MSE0/MSE00                %  0.0264   VERY BAD FIT
% Neural Model
 [ I N ] = size(input)                                 % [ 1 30 ]
 [ O N ] = size(target)                              % [ 1 30 ]
 Neq = N*O                                             % 30 =  No. of equations
% Nw = (I+1)*H+(H+1)*O = 1+3*H       % No. of unknown weights
% No overfitting Neq > Nw==> H <= Hub (upper bound)
 Hub  = -1+ceil( (Neq-O) / ( I+O+1) )  % 9
 Hmax = 9
 dH   = 1
 Hmin = 0  % Linear Model
 numH = length(Hmin:dH:Hmax) % 10
 Ntrials = 10
 rng(0)
 j=0
 for h=Hmin:dH:Hmax
    j=j+1
    if h==0
        net = patternnet([]);
        Nw = (I+1)*O
    else
        net = patternnet(h);
        Nw = (I+1)*h+(h+1)*O
    end
    for i=1:Ntrials
       net = configure(net, input,target);
       net.divideFcn = 'dividetrain';            % Default 'dividerand' is much worse
       [net tr y e ] = train(net,input,target);
       R2(i,j) = 1 - mse(e)/MSE00;
    end
 end
 R2 = R2   % 0.0264* ones(Ntrials,numH)     Same as Linear
Hope this helps.
*Thank you for formally accepting my answer *
Greg
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


