messo codice che segna i punti invece delle rette

This commit is contained in:
2025-01-29 14:03:46 +01:00
parent 194596b8b2
commit 45a5b07bda
11 changed files with 219 additions and 12 deletions

View File

@@ -21,6 +21,7 @@ int x[4][2] = {
// Dichiarazione dei metodi
Percettrone crea_percettrone();
double randomico();
double randomico_positivo();
double funzione_sigmoide(Percettrone, double, double);
void correggi_pesi(Percettrone*, double, double, double);
@@ -46,6 +47,11 @@ double randomico() {
return ((double)(rand() % 101 * 0.01 * 2 ) -1);
}
double randomico_positivo() {
// Genero numeri nell'intervallo [0,1]
return ((double)(rand() % 101 * 0.01));
}
double funzione_sigmoide(Percettrone p, double x1, double x2) {
double funzione = (x1 * p.w1) + (x2 * p.w2) + p.bias;
double potenza_e = exp(-funzione);
@@ -85,10 +91,16 @@ void stampa_risultati_layer_singolo(Percettrone p) {
}
void stampa_risultati_layer_multi(Percettrone p1, Percettrone p2, Percettrone pout) {
printf("\nPercettrone 1:\n");
printf("\t W1: %f, W2: %f, bias: %f\n", p1.w1, p1.w2, p1.bias);
printf("Percettrone 2:\n");
printf("\t W1: %f, W2: %f, bias: %f\n", p2.w1, p2.w2, p2.bias);
printf("Percettrone OUT:\n");
printf("\t W1: %f, W2: %f, bias: %f\n", pout.w1, pout.w2, pout.bias);
printf("\nPercettroni 1, 2 e out:\n");
printf("\np_ext_1.w1 = %f;", p1.w1);
printf("\np_ext_1.w2 = %f;", p1.w2);
printf("\np_ext_1.bias = %f;\n", p1.bias);
printf("\np_ext_2.w1 = %f;", p2.w1);
printf("\np_ext_2.w2 = %f;", p2.w2);
printf("\np_ext_2.bias = %f;\n", p2.bias);
printf("\npout.w1 = %f;", pout.w1);
printf("\npout.w2 = %f;", pout.w2);
printf("\npout.bias = %f;\n", pout.bias);
}