#31




Re: Perceptron Learning Algorithm
Quote:
A word of warning to others (although it sounds like everyone else on the forums is already past this point): You do in fact need to include w_0 (with x_i,0 = 1). I spent quite a while wrestling with my nonconverging PLA until I realized this was the issue (and then some more time wondering why my P(f(x) != g(x)) values were so weird, until I realized that I'd failed to account for the extra w_0 when computing f(x) using a 2D x instead of the appropriate 3D version...) I'd interpreted the value of w_0 from the inclass example as a threshold set by the bank for a creditworthy customer, but now I realize that in fact it's one of the learned parameters, which makes perfect sense in retrospect. 
#32




Re: Perceptron Learning Algorithm
While running through the population I first collect all the misfit points and then choose a random point to adjust the weights. The other approach could be to stop at the first misfit and correct the weights. What is practiced?

#33




Re: Perceptron Learning Algorithm
I chose to correct the weights at the first misfit, increase the count of iterations and start the algorithm again from the first point... it works fast so far... but I'm wondering if I should continue with the algorithm without restarting again and stopping only when all points satisfy h(x)=g(x)...

#34




Re: Perceptron Learning Algorithm
Quote:

#35




Re: Perceptron Learning Algorithm
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. 
#36




Re: Perceptron Learning Algorithm
Quote:

#37




Re: Perceptron Learning Algorithm
Quote:

#38




Re: Perceptron Learning Algorithm
Quote:
Code:
w = np.zeros( 3 ) done = False while not done: wrongpoints = 0 for p in points: if np.sign( np.dot(w, p) ) != targetFunction( p ): w = np.add( w, targetFunction( p ) * p ) wrongpoints += 1 break if wrongpoints == 0: done = True https://gist.github.com/2395395 and the one for the experiments: https://gist.github.com/2395409 
#39




Re: Perceptron Learning Algorithm
Quote:
Correction: My bad! Missed the 'break' statement 
#40




Re: Perceptron Learning Algorithm
Quote:
Yes, numpy is the best thing ever made for Python! Pseudoinverse of a matrix? np.pniv :) 
Thread Tools  
Display Modes  

