View Single Post
Old 04-15-2012, 04:47 PM
zsero zsero is offline
Junior Member
Join Date: Apr 2012
Posts: 6
Default Re: Perceptron Learning Algorithm

Originally Posted by julien View Post
I think it would be interesting to obtain a detailed example with the first few steps used to initialize and train the perceptron. Or a complete example if anybody is willing to share their code.

I was unable to implement correctly the perceptron before the deadline, and after spending an additional 5h in this exercise today, I still don't have a proper implementation.
Programming is not the issue, I'm a developer, but my issue is how to apply the theory.

I feel it's important to successfully code this algorithm, so I can successfully apply the theories we will learn in the next few lectures.
I've written the algorithm just based on the lecture and it worked. Here is the "core" of the algorithm (written in Python / Numpy):

w = np.zeros( 3 )
done = False

while not done:
    wrongpoints = 0
    for p in points:
        if np.sign(, p) ) != targetFunction( p ):
            w = np.add( w, targetFunction( p ) * p )
            wrongpoints += 1
    if wrongpoints == 0:
        done = True
If anyone is interested in the Python implementation, here is my full code with plotting:

and the one for the experiments:
Reply With Quote