没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
python实现简单神经网络算法实现简单神经网络算法
主要为大家详细介绍了python实现简单神经网络算法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
python实现简单神经网络算法,供大家参考,具体内容如下
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
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
资源评论
weixin_38624628
- 粉丝: 8
- 资源: 935
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功