顯示函數(shù)plotpv的2個(gè)參數(shù)是輸入向量和目標(biāo)函數(shù)
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返回分界線控點(diǎn),根據(jù)權(quán)W和閾值B的輸入繪制一條分界線
?
plotpc(W,B)
plotpc(W,B,H)包含從前一次調(diào)用中返回的控點(diǎn),在繪制新分界線之前,刪除舊線
?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
?
?
關(guān)于 PLOTPC
?Plot a classification line on a perceptron vector plot.
繪制一個(gè)分類線,根據(jù)權(quán)矩陣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)
?下面的代碼創(chuàng)建一個(gè)感知器,感知器是單層神經(jīng)元,采用閾值激活函數(shù),對一組輸入向量的響應(yīng)達(dá)到 元素為0或1的目標(biāo)輸出,實(shí)現(xiàn)對輸入向量進(jìn)行分類,下面這個(gè)代碼創(chuàng)建了這個(gè)分類線
???? 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})
?
我們把這個(gè)程序改一下
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個(gè)神經(jīng)元的感知器,其中P是輸入向量,T是目標(biāo)函數(shù)
>> net.b{1}
ans =
???? 0
>> net.iw{1,1}
ans =
???? 0???? 0
>>
?
>> plotpc(net.iw{1,1},net.b{1})
此時(shí)執(zhí)行沒有意義,因?yàn)闄?quán)值和閾值初始化為0
?
我們指定一個(gè)正確的權(quán)值和閾值
net.b{1}=-2
net.iw{1,1} =[1 1]
?plotpc(net.iw{1,1},net.b{1})
注意plotpc必須要在plotpv函數(shù)后執(zhí)行,可以看到分界線正確顯示出來
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

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