0% found this document useful (0 votes)
15 views1 page

AND - Ipynb - Colab

DL Feedforward

Uploaded by

apaturkar87
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

AND - Ipynb - Colab

DL Feedforward

Uploaded by

apaturkar87
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

16/10/2024, 21:27 AND.

ipynb - Colab

import numpy as np
def perceptron(x,y,learning_rate=0.01,epoch=1000):
weight=np.zeros(x.shape[1])
bias=0
for e in range(epoch):
for i in range(len(y)):
linear_output=np.dot(x[i],weight) + bias
y_prediction=1 if linear_output > 0 else 0
if y_prediction!=y[i]:
update=learning_rate *(y[i]-y_prediction)
weight+=update*x[i]
bias+=update
return weight,bias
def predict(x,weight,bias):
linear_output=np.dot(x,weight) + bias
return([1 if i>0 else 0 for i in linear_output])
x=np.array([[0,0],[0,1],[1,0],[1,1]])
y=np.array([0,0,0,1])
w,b=perceptron(x,y)
predictions=predict(x,w,b)
print("weight", w)
print("bias",b)
print("Predictions",predictions)

weight [0.02 0.01]


bias -0.02
Predictions [0, 0, 0, 1]

Start coding or generate with AI.

https://colab.research.google.com/drive/1z57QffIyIuQsTT11djeMXH85C6KadfGL#printMode=true 1/1

You might also like