provo a tracciare retta di layer1
This commit is contained in:
@@ -94,8 +94,8 @@ void disegna_legenda(int multi_layer) {
|
|||||||
textout_ex(screen, font, "Percettrone", 0 + 10, 0 + 10, colore_rosso, -1);
|
textout_ex(screen, font, "Percettrone", 0 + 10, 0 + 10, colore_rosso, -1);
|
||||||
else {
|
else {
|
||||||
textout_ex(screen, font, "Percettrone 1", 0 + 10, 0 + 10, colore_rosso, -1);
|
textout_ex(screen, font, "Percettrone 1", 0 + 10, 0 + 10, colore_rosso, -1);
|
||||||
textout_ex(screen, font, "Percettrone 2", 0 + 10, 0 + 20, colore_verde, -1);
|
//textout_ex(screen, font, "Percettrone 2", 0 + 10, 0 + 20, colore_verde, -1);
|
||||||
textout_ex(screen, font, "Percettrone out", 0 + 10, 0 + 30, colore_blu, -1);
|
textout_ex(screen, font, "Percettrone out", 0 + 10, 0 + 20, colore_blu, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
layer_multi
Executable file
BIN
layer_multi
Executable file
Binary file not shown.
@@ -82,12 +82,11 @@ void main()
|
|||||||
// Contatore per fermare il percettrone, se vale 4 significa che ha indovinato tutte e 4 le combinazioni
|
// Contatore per fermare il percettrone, se vale 4 significa che ha indovinato tutte e 4 le combinazioni
|
||||||
int corrette = 0;
|
int corrette = 0;
|
||||||
|
|
||||||
Retta *rette_p_ext_1 = (Retta *)malloc(sizeof(Retta));
|
//Retta *rette_p_ext_1 = (Retta *)malloc(sizeof(Retta));
|
||||||
Retta *rette_p_ext_2 = (Retta *)malloc(sizeof(Retta));
|
//Retta *rette_p_ext_2 = (Retta *)malloc(sizeof(Retta));
|
||||||
|
Retta *rette_layer_uno = (Retta *)malloc(sizeof(Retta));
|
||||||
Retta *rette_pout = (Retta *)malloc(sizeof(Retta));
|
Retta *rette_pout = (Retta *)malloc(sizeof(Retta));
|
||||||
|
|
||||||
int size_iniziale = sizeof(rette_p_ext_1);
|
|
||||||
|
|
||||||
// Soglia sigmoide
|
// Soglia sigmoide
|
||||||
double soglia_funzione_attivazione = 0.5;
|
double soglia_funzione_attivazione = 0.5;
|
||||||
|
|
||||||
@@ -101,8 +100,9 @@ void main()
|
|||||||
for (int z = 0; z < i; z++)
|
for (int z = 0; z < i; z++)
|
||||||
{
|
{
|
||||||
cls(tipo, 1);
|
cls(tipo, 1);
|
||||||
traccia_retta(rette_p_ext_1[z].m, rette_p_ext_1[z].q, colore_rosso);
|
//traccia_retta(rette_p_ext_1[z].m, rette_p_ext_1[z].q, colore_rosso);
|
||||||
traccia_retta(rette_p_ext_2[z].m, rette_p_ext_2[z].q, colore_verde);
|
//traccia_retta(rette_p_ext_2[z].m, rette_p_ext_2[z].q, colore_verde);
|
||||||
|
traccia_retta(rette_layer_uno[z].m, rette_layer_uno[z].q, colore_rosso);
|
||||||
traccia_retta(rette_pout[z].m, rette_pout[z].q, colore_blu);
|
traccia_retta(rette_pout[z].m, rette_pout[z].q, colore_blu);
|
||||||
//printf("Sto tracciando la retta p1 con coefficiente: %f e intercetta: %f\n", rette_p_ext_1[z].m, rette_p_ext_1[z].q);
|
//printf("Sto tracciando la retta p1 con coefficiente: %f e intercetta: %f\n", rette_p_ext_1[z].m, rette_p_ext_1[z].q);
|
||||||
//printf("Sto tracciando la retta p2 con coefficiente: %f e intercetta: %f\n", rette_p_ext_2[z].m, rette_p_ext_2[z].q);
|
//printf("Sto tracciando la retta p2 con coefficiente: %f e intercetta: %f\n", rette_p_ext_2[z].m, rette_p_ext_2[z].q);
|
||||||
@@ -170,17 +170,23 @@ void main()
|
|||||||
// Prevengo la divisione per zero
|
// Prevengo la divisione per zero
|
||||||
if(p_ext_1.w2 != 0 && p_ext_2.w2 != 0 && pout.w2 !=0)
|
if(p_ext_1.w2 != 0 && p_ext_2.w2 != 0 && pout.w2 !=0)
|
||||||
{
|
{
|
||||||
rette_p_ext_1[i].m = -(p_ext_1.w1 * x[j][0]) / p_ext_1.w2;
|
// rette_p_ext_1[i].m = -(p_ext_1.w1 * x[j][0]) / p_ext_1.w2;
|
||||||
rette_p_ext_1[i].q = -(p_ext_1.bias / p_ext_1.w2);
|
// rette_p_ext_1[i].q = -(p_ext_1.bias / p_ext_1.w2);
|
||||||
rette_p_ext_2[i].m = -(p_ext_2.w1 * x[j][0]) / p_ext_2.w2;
|
// rette_p_ext_2[i].m = -(p_ext_2.w1 * x[j][0]) / p_ext_2.w2;
|
||||||
rette_p_ext_2[i].q = -(p_ext_2.bias / p_ext_2.w2);
|
// rette_p_ext_2[i].q = -(p_ext_2.bias / p_ext_2.w2);
|
||||||
|
|
||||||
rette_pout[i].m = -(pout.w1 * x[j][0]) / pout.w2;
|
rette_pout[i].m = -(pout.w1 * x[j][0]) / pout.w2;
|
||||||
rette_pout[i].q = -(pout.bias / pout.w2);
|
rette_pout[i].q = -(pout.bias / pout.w2);
|
||||||
|
|
||||||
|
// somma delle rette (m1 + m2)x + (q1 + q2)
|
||||||
|
rette_layer_uno[i].m = rette_pout[i].m - ((-(p_ext_1.w1 * x[j][0]) / p_ext_1.w2) + (-(p_ext_2.w1 * x[j][0]) / p_ext_2.w2));
|
||||||
|
rette_layer_uno[i].q = rette_pout[i].q - ((-(p_ext_1.bias / p_ext_1.w2)) - (-(p_ext_2.bias / p_ext_2.w2)));
|
||||||
|
|
||||||
if (corrette != 4)
|
if (corrette != 4)
|
||||||
{
|
{
|
||||||
rette_p_ext_1 = (Retta *)realloc(rette_p_ext_1, sizeof(Retta) * (i + 2));
|
/* rette_p_ext_1 = (Retta *)realloc(rette_p_ext_1, sizeof(Retta) * (i + 2));
|
||||||
rette_p_ext_2 = (Retta *)realloc(rette_p_ext_2, sizeof(Retta) * (i + 2));
|
rette_p_ext_2 = (Retta *)realloc(rette_p_ext_2, sizeof(Retta) * (i + 2)); */
|
||||||
|
rette_layer_uno = (Retta *)realloc(rette_layer_uno, sizeof(Retta) * (i + 2));
|
||||||
rette_pout = (Retta *)realloc(rette_pout, sizeof(Retta) * (i + 2));
|
rette_pout = (Retta *)realloc(rette_pout, sizeof(Retta) * (i + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
layer_singolo
Executable file
BIN
layer_singolo
Executable file
Binary file not shown.
@@ -12,7 +12,7 @@ int MAX_EPOCHE = 10000;
|
|||||||
4: NOR
|
4: NOR
|
||||||
5: XNOR
|
5: XNOR
|
||||||
*/
|
*/
|
||||||
int tipo = 3;
|
int tipo = 4;
|
||||||
|
|
||||||
void stampa_risultati(Percettrone);
|
void stampa_risultati(Percettrone);
|
||||||
void sleep_ms(int);
|
void sleep_ms(int);
|
||||||
|
|||||||
Reference in New Issue
Block a user