Wednesday, 2 October 2013

Why won't Perceptron Learning Algorithm converge?

Why won't Perceptron Learning Algorithm converge?

I have implemented the Perceptron Learning Algorithm in Python as below.
Even with 500,000 iterations, it still won't converge.
I have a training data matrix X with target vector Y, and a weight vector
w to be optimized.
My update rule is:
while(exist_mistakes):
# dot product to check for mistakes
output = [np.sign(np.dot(X[i], w)) == Y[i] for i in range(0, len(X))]
# find index of mistake. (choose randomly in order to avoid repeating
same index.)
n = random.randint(0, len(X)-1)
while(output[n]): # if output is true here, choose again
n = random.randint(0, len(X)-1)
# once we have found a mistake, update
w = w + Y[n]*X[n]
Is this wrong? Or why is it not converging even after 500,000 iterations?

No comments:

Post a Comment