diff --git a/percettrone b/percettrone new file mode 100755 index 0000000..1572d01 Binary files /dev/null and b/percettrone differ diff --git a/percettrone.c b/percettrone.c index 5a94629..f4b3c9c 100644 --- a/percettrone.c +++ b/percettrone.c @@ -1,6 +1,11 @@ #include ; +#include ; #include ; +Percettrone p1 = creaPercettrone(); +Percettrone p2 = creaPercettrone(); +Percettrone p3 = creaPercettrone(); + struct struttura_percettrone { double w1; double w2; @@ -9,6 +14,35 @@ struct struttura_percettrone { }; typedef struct struttura_percettrone Percettrone; -void creaPercettrone() { +Percettrone creaPercettrone() { + srand(time(NULL)); + + Percettrone percettrone; -} \ No newline at end of file + percettrone.w1 = random(); + percettrone.w2 = random(); + percettrone.bias = random(); + percettrone.lre = 0.2; + + return percettrone; +} + +double random() { + // Genero numeri nell'intervallo [-1,1] + return ((double)(rand() % 101 * 0.01 * 2 ) -1); +} + +void main() { + creaPercettrone(); +} + + + + /* # il return verrĂ  confrontato col valore di soglia di attivazione + def funzione_sigmoide(self, x1, x2): + return (1 / (1 + math.exp(-((x1 * self.w1) + (x2 * self.w2) + self.bias)))) + + def correggi_pesi(self, gradiente_w1, gradiente_w2, gradiente_bias): + self.bias = self.bias - (gradiente_bias * self.lre) + self.w1 = self.w1 - (gradiente_w1 * self.lre) + self.w2 = self.w2 - (gradiente_w2 * self.lre) */ \ No newline at end of file