新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

python实现简单神经网络算法-创新互联

python实现简单神经网络算法,供大家参考,具体内容如下

创新互联是一家专注网站建设、网络营销策划、小程序开发、电子商务建设、网络推广、移动互联开发、研究、服务为一体的技术型公司。公司成立十多年以来,已经为1000+砂岩浮雕各业的企业公司提供互联网服务。现在,服务的1000+客户与我们一路同行,见证我们的成长;未来,我们一起分享成功的喜悦。

python实现二层神经网络

包括输入层和输出层

import numpy as np 
 
#sigmoid function 
def nonlin(x, deriv = False): 
  if(deriv == True): 
    return x*(1-x) 
  return 1/(1+np.exp(-x)) 
 
#input dataset 
x = np.array([[0,0,1], 
       [0,1,1], 
       [1,0,1], 
       [1,1,1]]) 
 
#output dataset 
y = np.array([[0,0,1,1]]).T 
 
np.random.seed(1) 
 
#init weight value 
syn0 = 2*np.random.random((3,1))-1 
 
for iter in xrange(100000): 
  l0 = x             #the first layer,and the input layer  
  l1 = nonlin(np.dot(l0,syn0))  #the second layer,and the output layer 
 
 
  l1_error = y-l1 
 
  l1_delta = l1_error*nonlin(l1,True) 
 
  syn0 += np.dot(l0.T, l1_delta) 
print "outout after Training:" 
print l1 

新闻标题:python实现简单神经网络算法-创新互联
转载来于:http://www.wjwzjz.com/article/dgshec.html
在线咨询
服务热线
服务热线:028-86922220
TOP