provo a tracciare retta di layer1
This commit is contained in:
@@ -82,12 +82,11 @@ void main()
|
||||
// Contatore per fermare il percettrone, se vale 4 significa che ha indovinato tutte e 4 le combinazioni
|
||||
int corrette = 0;
|
||||
|
||||
Retta *rette_p_ext_1 = (Retta *)malloc(sizeof(Retta));
|
||||
Retta *rette_p_ext_2 = (Retta *)malloc(sizeof(Retta));
|
||||
//Retta *rette_p_ext_1 = (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));
|
||||
|
||||
int size_iniziale = sizeof(rette_p_ext_1);
|
||||
|
||||
// Soglia sigmoide
|
||||
double soglia_funzione_attivazione = 0.5;
|
||||
|
||||
@@ -101,8 +100,9 @@ void main()
|
||||
for (int z = 0; z < i; z++)
|
||||
{
|
||||
cls(tipo, 1);
|
||||
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_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_layer_uno[z].m, rette_layer_uno[z].q, colore_rosso);
|
||||
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 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
|
||||
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].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].q = -(p_ext_2.bias / p_ext_2.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_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_pout[i].m = -(pout.w1 * x[j][0]) / 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)
|
||||
{
|
||||
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_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_layer_uno = (Retta *)realloc(rette_layer_uno, sizeof(Retta) * (i + 2));
|
||||
rette_pout = (Retta *)realloc(rette_pout, sizeof(Retta) * (i + 2));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user