Problem when creating multiple objects, the variables are the same for some reason

1

I'm doing a small neural network that detects the letter the thing is that I get stuck on something that may seem basic, I create a neuron object for each letter, it's only those 7, each letter has 3 different letters as well as pixels something like that.

..##...

...#...

...#...

..#.#..

..#.#..

.#####.

.#...#.

.#...#.

###.###

That is an "A" and so with all the letters

I have 3 designs for each type of letter I read the patterns and I pass them to 3 arrays and then those arrays I convert them to a bipolar array like "1" and "-1" but when I print those bipolar arrays to see if I did it well (I print the first "a" and the first "b") and print the same thing.

My constructor is like this, later I put the method I use to read the files.

public elPratronizaje() throws IOException {
    a = new Neurona("C:\Users\CHOME\Desktop\Letras_entrenamiento\A.txt");
    b = new Neurona("C:\Users\CHOME\Desktop\Letras_entrenamiento\B.txt");
    c = new Neurona("C:\Users\CHOME\Desktop\Letras_entrenamiento\C.txt");
    d = new Neurona("C:\Users\CHOME\Desktop\Letras_entrenamiento\D.txt");
    e = new Neurona("C:\Users\CHOME\Desktop\Letras_entrenamiento\E.txt");
    j = new Neurona("C:\Users\CHOME\Desktop\Letras_entrenamiento\J.txt");
    k = new Neurona("C:\Users\CHOME\Desktop\Letras_entrenamiento\K.txt");

    for (int i = 0; i < 64; i++) {
        System.out.print(a.getLetrasBipolares()[0][i]);
    }
    System.out.println();
    System.out.println(a.getLetrasBipolares()[0].length);

    for (int i = 0; i < 64; i++) {
        System.out.print(b.getLetrasBipolares()[0][i]);
    }
    System.out.println();
    System.out.println(b.getLetrasBipolares()[0].length);

}

Method I use to read files

void leer(String archivo) throws FileNotFoundException, IOException {
    FileReader f = new FileReader(archivo);
    BufferedReader b = new BufferedReader(f);
    while((cadena = b.readLine())!=null) {
        letra += cadena;
        int aux = letra.length();
       // System.out.println(cadena);
    }
    b.close();
}

and this to convert the text to bipolar strings of type int, which is the constructor of the neuron class

public Neurona(String archivo) throws IOException {
    leer(archivo);
    letras[0] = "."+letra.substring(0,63);
    letras[1] = "."+letra.substring(63,126);
    letras[2] = "."+letra.substring(126,189);
    letrasAux[0] = letras[0].toCharArray();
    letrasAux[1] = letras[1].toCharArray();
    letrasAux[2] = letras[2].toCharArray();
    for (int i = 0; i < 64 ; i++) {
        if (letrasAux[0][i] == '#'){
            letrasBipolares[0][i] = 1;
        }else if (letrasAux[0][i] == '.'){
            letrasBipolares[0][i] = -1;
        }
    }
    for (int i = 0; i < 64 ; i++) {
        if (letrasAux[1][i] == '#'){
            letrasBipolares[1][i] = 1;
        }else if (letrasAux[1][i] == '.'){
            letrasBipolares[1][i] = -1;
        }
    }
    for (int i = 0; i < 64 ; i++) {
        if (letrasAux[2][i] == '#'){
            letrasBipolares[2][i] = 1;
        }else if (letrasAux[2][i] == '.'){
            letrasBipolares[2][i] = -1;
        }
    }
}
    
asked by Gnaevs 04.06.2018 в 22:29
source

0 answers