import java.text.DecimalFormat; public class XOR{ private static double fdt(double x,Boolean deriv){ if (deriv) return x*(1-x); return 1/(1+Math.exp(-x)); } //applica fdt a una matrice private static double[][] fdt_mat(double[][] x,Boolean deriv){ if (deriv) { for(int i=0; i 0) iterazioni=Integer.parseInt(args[0]); //Matrice degli input, 4x3 double X[][] = { {0d,0d,1d}, {0d,1d,1d}, {1d,0d,1d}, {1d,1d,1d} }; //Matrice degli output desiderati \xi, 4x1, una riga per ogni esempio double Y[][] = { {0d}, {1d}, {1d}, {0d} }; double Ytest[][] = { {1d}, {0d}, {0d}, {1d} }; //synapsi, primo set, 3x4 double[][] syn0 = new double[X[0].length][hidden_layer]; syn0 = randomize_matrix(syn0); //synapsi, secondo set, 4x1 double[][] syn1 = new double[hidden_layer][1]; syn1 = randomize_matrix(syn1); //fase forward iniziale double[][] l0 = X; double[][] l1 = dot_product(l0,syn0); double[][] l2 = dot_product(l1,syn1); for(int iter=0; iter