programmando

This commit is contained in:
2025-01-24 19:02:24 +01:00
parent 18ee9bd634
commit 1bb9fd7021
2 changed files with 36 additions and 2 deletions

BIN
percettrone Executable file

Binary file not shown.

View File

@@ -1,6 +1,11 @@
#include <stdlib.h>; #include <stdlib.h>;
#include <stdio.h>;
#include <time.h>; #include <time.h>;
Percettrone p1 = creaPercettrone();
Percettrone p2 = creaPercettrone();
Percettrone p3 = creaPercettrone();
struct struttura_percettrone { struct struttura_percettrone {
double w1; double w1;
double w2; double w2;
@@ -9,6 +14,35 @@ struct struttura_percettrone {
}; };
typedef struct struttura_percettrone Percettrone; typedef struct struttura_percettrone Percettrone;
void creaPercettrone() { Percettrone creaPercettrone() {
srand(time(NULL));
Percettrone percettrone;
} 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) */