Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

非線形問題の線形近似

y 非線形入出力問題への最小残差平方和の線形近似を求めるように線形ニューロンの学習を行います。

X は、4 つの 1 要素入力パターン (列ベクトル) を定義します。T は、関連する 1 要素ターゲット (列ベクトル) を定義します。X の値と T の値の関係は非線形であることに注意してください。つまり、上記の X および T の値の 4 つのセットすべてについて、X*W+B = T となるような W と B は存在しません。

X = [+1.0 +1.5 +3.0 -1.2];
T = [+0.5 +1.1 +3.0 -1.0];

ERRSURF は、可能な重みとバイアスの値の y 範囲を使用して y ニューロンの誤差を計算します。PLOTES は、この誤差曲面と、その下の y 等高線図を併せてプロットします。

最適な重みとバイアスの値は、誤差曲面の最低点が得られる値です。y の完全な線形近似は不可能であるため、最小値は 0 より大きい誤差をもつことに注意してください。

w_range =-2:0.4:2;  b_range = -2:0.4:2;
ES = errsurf(X,T,w_range,b_range,'purelin');
plotes(w_range,b_range,ES);

Figure contains 2 axes objects. Axes object 1 with title Error Surface, xlabel Weight W, ylabel Bias B contains 2 objects of type surface. Axes object 2 with title Error Contour, xlabel Weight W, ylabel Bias B contains 2 objects of type surface, contour.

MAXLINLR は、y 線形ネットワークの学習のための最速かつ安定した学習率を求めます。NEWLIN は y 線形ニューロンを作成します。NEWLIN は、次の引数を取ります。1) R 個の入力要素の最小値と最大値の R 行 2 列の行列、2) 出力ベクトルの要素数、3) 入力遅延ベクトル、4) 学習率。

maxlr = maxlinlr(X,'bias');
net = newlin([-2 2],1,[0],maxlr);

最大エポック数を設定して既定の学習パラメーターをオーバーライドします。これにより、学習は確実に停止します。

net.trainParam.epochs = 15;

学習のパスを示すために、時間 y で 1 エポックのみ学習させ、エポックごとに PLOTEP を呼び出します (ここではコードは示されません)。プロットは学習の y 履歴を示します。各点はエポックを表し、青い線は学習規則 (既定では Widrow・Hoff) によって行われる各変更を示します。

% [net,tr] = train(net,X,T);
net.trainParam.epochs = 1;
net.trainParam.show = NaN;
h=plotep(net.IW{1},net.b{1},mse(T-net(X)));     
[net,tr] = train(net,X,T);                                                    
r = tr;
epoch = 1;
while epoch < 15
   epoch = epoch+1;
   [net,tr] = train(net,X,T);
   if length(tr.epoch) > 1
      h = plotep(net.IW{1,1},net.b{1},tr.perf(2),h);
      r.epoch=[r.epoch epoch]; 
      r.perf=[r.perf tr.perf(2)];
      r.vperf=[r.vperf NaN];
      r.tperf=[r.tperf NaN];
   else
      break
   end
end

Figure Neural Network Training (27-Jul-2023 15:31:22) contains an object of type uigridlayout.

Figure contains 2 axes objects. Axes object 1 with title Error Surface, xlabel Weight W, ylabel Bias B contains 32 objects of type surface, line. One or more of the lines displays its values using only markers Axes object 2 with title Error Contour, xlabel Weight W, ylabel Bias B contains 17 objects of type surface, contour, line. One or more of the lines displays its values using only markers

tr=r;

学習関数は、学習済みネットワークおよび学習性能 (tr) の y 履歴を出力します。ここでは、誤差が学習エポックに関してプロットされています。

誤差が 0 にはならないことに注意してください。この問題は非線形であるため、y の誤差 0 の線形解は不可能です。

plotperform(tr);

Figure Performance (plotperform) contains an axes object. The axes object with title Best Training Performance is 2.865 at epoch 0, xlabel 1 Epochs, ylabel Mean Squared Error (mse) contains 6 objects of type line. One or more of the lines displays its values using only markers These objects represent Train, Best.

次に、SIM を使用して、元の入力の 1 つである -1.2 でアソシエーターをテストし、ターゲットである 1.0 を返すかどうかを確認します。

結果は 0.5 にあまり近くありません。これは、ネットワークが y 非線形問題の最適な線形近似であるためです。

x = -1.2;
y = net(x)
y = -1.1803