顯示函數plotpv的2個參數是輸入向量和目標函數
1)
>> P=[0 2 3 1 5 0 6
????? 2 9 0 7 1 0 0]
P =
???? 0???? 2???? 3???? 1???? 5???? 0???? 6
???? 2???? 9???? 0???? 7???? 1???? 0???? 0
>> t=[0 1 0 1 1 0 0]
t =
???? 0???? 1???? 0???? 1???? 1???? 0???? 0
?
>>plotpv(P,T)
?
?
2)
>> P=[0 2 3 1 5 0 6
2 9 0 7 1 0 0
0 9 2 1 8 0 9]
P =
???? 0???? 2???? 3???? 1???? 5???? 0???? 6
???? 2???? 9???? 0???? 7???? 1???? 0???? 0
???? 0???? 9???? 2???? 1???? 8???? 0???? 9
>> T=[1 0 0 0 0 1 0]
T =
???? 1???? 0???? 0???? 0???? 0???? 1???? 0
>> plotpv(P,T)
>>
?
?
3、plotpc返回分界線控點,根據權W和閾值B的輸入繪制一條分界線
?
plotpc(W,B)
plotpc(W,B,H)包含從前一次調用中返回的控點,在繪制新分界線之前,刪除舊線
?P=[ -0.3 -0.5 +0.6 -0.1 -0.8
-0.5 +0.6 -0.2 +0.5 -0.6 ]
T=[0 1 1 1 0]
plotpv(P,T)
net=newp([-10 2; -5 20],1)
hold on
linehandle=plotpc(net.iw{1},net.b{1})
net.adaptParam.passes=3
linehandle=plotpc(net.iw{1},net.b{1})
for a=1:25
[net,Y,E]=adapt(net,P,T)
linehandle=plotpc(net.iw{1},net.b{1},linehandle)
drawnow
end
?
?
關于 PLOTPC
?Plot a classification line on a perceptron vector plot.
繪制一個分類線,根據權矩陣W和閾值矩陣B
?
?? Syntax
?
???? plotpc(W,b)
???? plotpc(W,b,h)
?
?? Description
?
???? PLOTPC(W,B) takes these inputs,
?????? W - SxR weight matrix (R must be 3 or less).
?????? B - Sx1 bias vector.
???? and returns a handle to a plotted classification line.
??
???? PLOTPC(W,B,H) takes these inputs,
?????? H - Handle to last plotted line.
???? and deletes the last line before plotting the new one.
??
???? This function does not change the current axis and is intended
???? to be called after PLOTPV.
?
?
?? Example
?
???? The code below defines and plots the inputs and targets for a
???? perceptron:
?
?????? p = [0 0 1 1; 0 1 0 1];
?????? t = [0 0 0 1];
?????? plotpv(p,t)
?下面的代碼創建一個感知器,感知器是單層神經元,采用閾值激活函數,對一組輸入向量的響應達到 元素為0或1的目標輸出,實現對輸入向量進行分類,下面這個代碼創建了這個分類線
???? The following code creates a perceptron with inputs ranging
???? over the values in P, assigns values to its weights
???? and biases, and plots the resulting classification line.
?
?????? net = newp(minmax(p),1);
?????? net.iw{1,1} = [-1.2 -0.5];
?????? net.b{1} = 1;
?????? plotpc(net.iw{1,1},net.b{1})
?
我們把這個程序改一下
P=[0 1 0 1 1;1 1 1 0 0]
T=[0 1 0 0 0]
net = newp(minmax(P),1)
plotpv(P,T)
hold on
生成1個神經元的感知器,其中P是輸入向量,T是目標函數
>> net.b{1}
ans =
???? 0
>> net.iw{1,1}
ans =
???? 0???? 0
>>
?
>> plotpc(net.iw{1,1},net.b{1})
此時執行沒有意義,因為權值和閾值初始化為0
?
我們指定一個正確的權值和閾值
net.b{1}=-2
net.iw{1,1} =[1 1]
?plotpc(net.iw{1,1},net.b{1})
注意plotpc必須要在plotpv函數后執行,可以看到分界線正確顯示出來
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
