<分区>
我想知道是否有人有 python 神经网络的一些示例代码。如果有人知道某种带有完整演练的教程那会很棒,但是示例源也很棒!
谢谢
<分区>
我想知道是否有人有 python 神经网络的一些示例代码。如果有人知道某种带有完整演练的教程那会很棒,但是示例源也很棒!
谢谢
最佳答案
在 ubuntu 论坛上发现了这个有趣的讨论 http://ubuntuforums.org/showthread.php?t=320257
import time
import random
# Learning rate:
# Lower = slower
# Higher = less precise
rate=.2
# Create random weights
inWeight=[random.uniform(0, 1), random.uniform(0, 1)]
# Start neuron with no stimuli
inNeuron=[0.0, 0.0]
# Learning table (or gate)
test =[[0.0, 0.0, 0.0]]
test+=[[0.0, 1.0, 1.0]]
test+=[[1.0, 0.0, 1.0]]
test+=[[1.0, 1.0, 1.0]]
# Calculate response from neural input
def outNeuron(midThresh):
global inNeuron, inWeight
s=inNeuron[0]*inWeight[0] + inNeuron[1]*inWeight[1]
if s>midThresh:
return 1.0
else:
return 0.0
# Display results of test
def display(out, real):
if out == real:
print str(out)+" should be "+str(real)+" ***"
else:
print str(out)+" should be "+str(real)
while 1:
# Loop through each lesson in the learning table
for i in range(len(test)):
# Stimulate neurons with test input
inNeuron[0]=test[i][0]
inNeuron[1]=test[i][1]
# Adjust weight of neuron #1
# based on feedback, then display
out = outNeuron(2)
inWeight[0]+=rate*(test[i][2]-out)
display(out, test[i][2])
# Adjust weight of neuron #2
# based on feedback, then display
out = outNeuron(2)
inWeight[1]+=rate*(test[i][2]-out)
display(out, test[i][2])
# Delay
time.sleep(1)
编辑:还有一个名为 chainer 的框架 https://pypi.python.org/pypi/chainer/1.0.0
关于python - 神经网络示例源代码(最好是 Python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1514573/
相关文章:
python - 检测 QWebEngineView 上的鼠标点击
neural-network - 如何用 MLP 训练乘法器?
machine-learning - 在caffe中定义新层时如何获取学习率或迭代次数
python - 加载巨大的 XML 文件并处理 MemoryError
python - 调度程序使 python 脚本运行但不生成 csv 文件
python - 分段上传到 Amazon Glacier : Content-Range incompatible with Content-Length