亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

正在回答

4 回答

ppn?=?Perceptron(eta=0.1,?n_iter=10)
ppn.fit(X,?y)
plt.plot(range(1,?len(ppn.errors_)?+?1),?ppn.errors_,?marker='o')
plt.xlabel("Epochs")
plt.ylabel("error?count")
plt.show()
from?matplotlib.colors?import?ListedColormapdef?plot_decision_region(X,?y,?classifier,?resolution=0.02):
????marker?=?('s',?'x',?'o',?'v')
????colors?=?('red',?'blue',?'lightgreen',?'gray',?'cyan')????#?len(np.unique(y)=2
????cmap?=?ListedColormap(colors[:len(np.unique(y))])????#?花莖的長度
????x1_min,?x1_max?=?X[:,?0].min()?-?1,?X[:,?0].max()????#?花瓣的長度
????x2_min,?x2_max?=?X[:,?1].min()?-?1,?X[:,?1].max()
????print(x1_min,?x1_max)
????print(x2_min,?x2_max)????#?(備注)
????xx1,?xx2?=?np.meshgrid(np.arange(x1_min,?x1_max,?resolution),?np.arange(x2_min,?x2_max,?resolution))????#?輸出語句
????print(np.arange(x1_min,?x1_max,?resolution).shape)
????print(np.arange(x1_min,?x1_max,?resolution))
????print(xx1.shape)
????print(xx1)
????print(np.arange(x2_min,?x2_max,?resolution).shape)
????print(np.arange(x2_min,?x2_max,?resolution))
????print(xx2.shape)
????print(xx2)#?執行語句plot_decision_region(X,?y,?ppn,?resolution=0.02)
備注:
????將np.arange()中的向量擴展成一個矩陣

????a?=?np.arange(x1_min,?x1_max,?resolution)?向量元素為185個
????xx1[255,?185],將a中的元素作為一行,重復255行
????b?=?np.arange(x2_min,?x2_max,?resolution)?向量元素為255個
????xx2[255,?185],將b中的元素作為一列,重復185列

謝謝采納~

2 回復 有任何疑惑可以回復我~

初始函數再運行一遍,Perceptron在里面

0 回復 有任何疑惑可以回復我~
Perception應改為?Perceptron


0 回復 有任何疑惑可以回復我~
#1

Nikola451

perception not defined 換成 Perceptron也沒用是怎么回事請問
2020-03-06 回復 有任何疑惑可以回復我~

參考視頻開頭,補上相關代碼,發現前面很多錯誤。

參考視頻開始,在前面不上代碼:

ppn?=?Perception(eta=0.1,?n_iter=10)
ppn.fit(X,?Y)
plt.plot(range(1,?len(ppn.errors_)?+?1),?ppn.errors_,?marker='o')
plt.xlabel("Epochs")
plt.ylabel("error?count")
plt.show()

處理掉一些錯誤:

1、感知器類里面的 初始化函數 應該是__init__,(寫成了__int__)

2、類里面初始化權重向量np.zeros,(寫成了np.zero)

1 回復 有任何疑惑可以回復我~
#1

Nikola451

perception not defined 是怎么回事請問
2020-03-06 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

沒有講ppn相關的內容

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號