init commit
This commit is contained in:
31
python/xor.py
Normal file
31
python/xor.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import backprop
|
||||
|
||||
patterns=[
|
||||
[[0,0], [0]],
|
||||
[[0,1], [1]],
|
||||
[[1,0], [1]],
|
||||
[[1,1], [0]],
|
||||
]
|
||||
|
||||
print 'Init Network ....'
|
||||
nn=backprop.NN(2,2,1)
|
||||
print 'Done ....'
|
||||
cpt=0
|
||||
|
||||
while 1:
|
||||
cpt=cpt+1;
|
||||
error=nn.trainAll(patterns)
|
||||
if error<0.01: break
|
||||
if cpt>10: break
|
||||
# if nn.epochs%100==0:
|
||||
print '%d: 100 step error=%1.6f'%(nn.epochs,error)
|
||||
|
||||
|
||||
print '%d: Total Error = %1.6f'%(nn.epochs,error)
|
||||
|
||||
|
||||
for input,target in patterns:
|
||||
error,output=nn.testOne(input,target)
|
||||
print '%1.6f'%error,input,target,output
|
||||
|
||||
|
||||
Reference in New Issue
Block a user