A python program for neural network trained with backpropagation with sigmoid function

import numpy as np
def nonlin(x,deriv=False):
if(deriv==True):
return x*(1-x)
return 1/(1+np.exp(-x))
X = np.array([ [0,0,1],
[0,1,1],
[1,0,1],
[1,1,1] ])
y = np.array([[0,0,1,1]]).T
np.random.seed(1)
syn0 = 2*np.random.random((3,1)) - 1
for iter in range(10000):
l0 = X
l1 = nonlin(np.dot(l0,syn0))
l1_error = y - l1
l1_delta = l1_error * nonlin(l1,True)
syn0 += np.dot(l0.T,l1_delta)
print ("Output After Training:")
print (l1)

6 comments:

Unknown said...
This comment has been removed by a blog administrator.
Bhanu Sree said...

It is so nice article thank you for sharing this valuable content
Python Flask Training in Ameerpet
Python Flask Training in Hyderabad
Python Flask Online Training
Flask Framework Training
Python Flask Training

Training Institute said...

We offer Python Training in Gurgaon to freshers and working professionals as per their skill level.
For More Info: Python Course in Gurgaon

KARTHIK said...

It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
http://chennaitraining.in/sap-abap-training-in-chennai/
http://chennaitraining.in/sap-apo-training-in-chennai/
http://chennaitraining.in/sap-ariba-training-in-chennai/
http://chennaitraining.in/sap-basis-training-in-chennai/
http://chennaitraining.in/bi-bw-training-in-chennai/
http://chennaitraining.in/sap-bo-training-in-chennai/
http://chennaitraining.in/sap-bods-training-in-chennai/
http://chennaitraining.in/sap-crm-training-in-chennai/

indiantrendingblog said...

Thanks for sharing this great article.
Python web developing Company

Abu samad said...

Wow, it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and I got more information from your blog. Best Python Online Training in Pune, Mumbai, Delhi NCR