神经学习初步

2018-03-01 11:09:29来源:oschina作者:小邓爸爸人点击

分享

import numpy as np b = 0 a = 0.5 x = np.array([[b,1,1],[b,1,0],[b,0,0],[b,0,1]]) d = np.array([1,1,0,1]) w = np.array([b,0,0]) def sgn(v):if v >=0:return 1else:return 0 def comy(myw,myx):return sgn(np.dot(myw.T,myx)) def neww(oldw,myd,myx,a):return oldw+a*(myd-comy(oldw,myx))*myx i = 0 for xn in x:w = neww(w,d[i],xn,a)i+=1 for xn in x:w = neww(w,d[i],xn,a)i += 1 for xn in x:print("%d and %d => %d")%(xn[1],xn[2],comy(w,xn))

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台