17 lines
518 B
Python
17 lines
518 B
Python
class Percettrone:
|
|
|
|
def __init__(self, w1 = 1, w2 = 1, bias = 1, lre = 1):
|
|
self.w1 = w1
|
|
self.w2 = w2
|
|
self.bias = bias
|
|
self.lre = lre
|
|
|
|
def funzione_gradino(self, x1, x2):
|
|
if ((x1 * self.w1) + (x2 * self.w2) + self.bias) >= 0:
|
|
return 1
|
|
return 0
|
|
|
|
def correggi_pesi(self, x1, x2, errore):
|
|
self.bias = self.bias + (errore * self.lre)
|
|
self.w1 = self.w1 + (errore * x1 * self.lre)
|
|
self.w2 = self.w2 + (errore * x2 * self.lre) |