用python完毕的总结3层神经网络

图片 1

importnumpyasnpdefsigmoid(x):return1/(1+np.exp(x))defstep_function(x):returnnp.array(x0,dtype=int)definit_network():network={}network[‘W1’]=np.array([[0.1,0.2,0.3,0.4],[0.05,0.15,0.25,0.35]])network[‘W2’]=np.array([[0.17,0.27,0.37],[0.23,0.33,0.43],[0.34,0.44,0.54],[0.56,0.66,0.76]])network[‘W3’]=np.array([[0.234,0.345],[0.222,0.333],[0.123,0.789]])network[‘b1’]=np.array([1.0,1.1,1.2,1.3])network[‘b2’]=np.array([0.78,0.88,0.98])network[‘b3’]=np.array([1.6,1,7])returnnetworkdefforward(network,x):W1,W2,W3=network[‘W1’],network[‘W2’],network[‘W3’]b1,b2,b3=network[‘b1’],network[‘b2’],network[‘b3’]a1=np.dot(x,W1)+b1z1=sigmoid(a1)a2=np.dot(z1,W2)+b2z2=sigmoid(a2)a3=np.dot(z2,W3)+b3x=np.array([0.34,0.61])network=init_network(卡塔尔(قطر‎y=forward(network,x卡塔尔国print(y卡塔尔国错误如图,4×3×2的兴风作浪形式,求大佬看看

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website