funziona and e or solo se metto bias < -1 in uno dei percettroni input
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class Percettrone:
|
||||
|
||||
def __init__(self, w1 = 0, w2 = 0, bias = 0, lre = 1):
|
||||
def __init__(self, w1 = 1, w2 = 1, bias = 1, lre = 1):
|
||||
self.w1 = w1
|
||||
self.w2 = w2
|
||||
self.bias = bias
|
||||
@@ -11,16 +11,7 @@ class Percettrone:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def valuta(self, x1, x2, risultato_atteso):
|
||||
y = self.funzione_gradino(x1, x2)
|
||||
errore = risultato_atteso - y
|
||||
return errore
|
||||
|
||||
def correggi_pesi(self, x1, x2, errore):
|
||||
self.bias = self.bias + (errore * self.lre)
|
||||
#print(f"errore: {errore * self.bias}")
|
||||
self.w1 = self.w1 + (errore * x1 * self.lre)
|
||||
self.w2 = self.w2 + (errore * x2 * self.lre)
|
||||
|
||||
def get_pesi(self):
|
||||
return (self.w1, self.w2, self.bias)
|
||||
self.w2 = self.w2 + (errore * x2 * self.lre)
|
||||
Reference in New Issue
Block a user