Det finns batch-inlärning när man itererar över hela sättet tills man klassificerar allt rätt och då blir uppdateringsregeln:
w = w + d*e*x
där w är viktvektorn, d är inlärningshastigheten, e är felet i klassificeringen, dvs
e = y-w*x
och x är indatan.
Detta fungerar bra för mig men när det kommer till stokastisk inlärning så får jag inte rätt på det och jag hittar inte heller mycket information om hur det skall fungera. På något ställe hittade jag (hittar tyvärr inte den PDFen nu) att uppdateringsregeln såg lika dan ut bara att man skippar inlärningsfaktorn, sätter den till 1 istället. Men detta har jag problem att få till eftersom den överkompenserar något enormt.. Här är tex en tentauppgift:
Kod: Markera allt
Running the perceptron on an example:
(a) You will use the set below corresponding to class 0 and class 1:
Negative examples:
(2, 1), (3, 2), (5, 1)
Positive examples:
(1, 3), (2, 5), (2, 3)
And you will draw the points in a two-dimensional plane as well
as a line separating the two classes.
(b) Run manually the perceptron update rule on the examples. You
will start from a weight vector of ones and you will use a stochastic
update rule. You will present the examples in the same order as
above, that is: (2, 1), (3, 2), (5, 1), (1, 3), (2, 5), (2, 3). You
should be able to find the weight vector in two epochs
Om jag börjar köra detta med min update regel får jag:
w = [1 1 1], x=[1 2 1]' -> e = -4 -> w = [-3 -7 -3]
w = [-3 -7 -3], x=[1 3 2]' -> e = 30 -> w = [27 83 57]
w = [27 83 57], x=[1 5 1]' -> e = -499 -> w = [-472 -2412 -442]
Redan här ser man ju att det bara kommer bli värre och värre i oscilleringarna..
Någon som har koll på detta? Att lägga till en inlärningsfaktor eller att normalisera kan ju eventuellt avhjälpa problemet, men är det verkligen så man skall göra?