CYPRUS INTERNATIONAL UNIVERSITY
ENGINEERING FACULTY
NEURAL NETWORKS MODELING AND ANALYSIS
HOMEWORK 1
Q1) Implement the Perceptron Learning Algorithm given below for 2-input perceptron by
using any programming language.
Learning Algorithm steps:
1. Initialise weights and threshold.
Set wi(t), (1 ≤ i ≤ m) to be the weight i at time t, and ø to be the threshold value in the output
node.
Set wi to small random values, thus initialising the weights and threshold.
2. Present input and desired output
Present input x0 and x1,x2,...,xm and desired output d(t)
3. Calculate the actual output
y(t) = f[w0(t) x0(t)+ w1(t)x1(t) + w2(t)x2(t) + .... + wm(t)xm(t)]
4. Adapts weights
wi(t + 1) = wi(t) + µ[d(t) − y(t)]xi(t) , for .
Steps 3 and 4 are repeated until the iteration error is less than a user-specified error threshold
or a predetermined number of iterations have been completed.
Use learning rate as 0.1 in your implementation.
Q2) Test your implementation with basic Boolean functions given below, by using initial
weights of 0.1 , 0.4.
AND OR
X0 X1 Y X0 X1 Y
+1 +1 +1 +1 +1 +1
+1 -1 -1 +1 -1 +1
-1 +1 -1 -1 +1 +1
-1 -1 -1 -1 -1 -1
Submission: Upload your report and your simulation codes through moodle.