Jump to content

AI with Java Netbeans 16, Ant


Dietmar

Recommended Posts

By the way,

without counting numbers together (Quersumme) and without factors (n Modulo 3 = 0),

ChatGPT cant see, if a number is a Multiplier of 3 or not. I make this test today evening. ChatGPT tells me, that it has no idea,

how to find this out without any given formula.

At once I understand the same crazy result by my Neural Network today by 100%

Dietmar

 

Link to comment
Share on other sites


This program learns the multipler of 2, nice :cheerleader:.

It then stores the learning in a file

Dietmar

 

package multi;


import org.neuroph.core.data.DataSet;
import org.neuroph.core.data.DataSetRow;
import org.neuroph.nnet.MultiLayerPerceptron;
import org.neuroph.nnet.learning.BackPropagation;

import java.util.Scanner;

public class Multi {

    public static void main(String[] args) {
        // create MultiLayerPerceptron neural network
        MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(3, 4,4, 2);
        neuralNet.setLearningRule(new BackPropagation());

        // create training set
        DataSet trainingSet = new DataSet(3, 2);
        trainingSet.add(new DataSetRow(new double[]{1, 2, 3}, new double[]{0, 1})); //odd
        trainingSet.add(new DataSetRow(new double[]{2, 2, 2}, new double[]{1, 0})); //even
        trainingSet.add(new DataSetRow(new double[]{4, 6, 0}, new double[]{1, 0})); //even
        trainingSet.add(new DataSetRow(new double[]{0, 0, 1}, new double[]{0, 1})); //odd
        
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("Enter a comma-separated list of 3 numbers or 'exit' to quit:");
            String inputStr = scanner.nextLine();

            if (inputStr.equals("exit")) {
                break;
            }

            String[] inputStrArray = inputStr.split(",");
            double[] input = new double[3];
            for (int i = 0; i < 3; i++) {
                input[i] = Double.parseDouble(inputStrArray[i].trim());
            }

            neuralNet.setInput(input);
            neuralNet.calculate();

            double[] output = neuralNet.getOutput();
            System.out.printf("Network prediction: %.2f odd, %.2f even%n", output[0], output[1]);

            if (output[0] > output[1]) {
                System.out.print("I think this is odd. Is that correct? (y/n) ");
                String answer = scanner.nextLine();
                if (answer.equals("y")) {
                    trainingSet.add(new DataSetRow(input, new double[]{1, 0})); //correcting as odd
                } else {
                    trainingSet.add(new DataSetRow(input, new double[]{0, 1})); //correcting as even
                }
            } else {
                System.out.print("I think this is even. Is that correct? (y/n) ");
                String answer = scanner.nextLine();
                if (answer.equals("y")) {
                    trainingSet.add(new DataSetRow(input, new double[]{0, 1})); //correcting as even
                } else {
                    trainingSet.add(new DataSetRow(input, new double[]{1, 0})); //correcting as odd
                }
            }

            // train neural network with updated training set
            neuralNet.learn(trainingSet);
        }

        // save trained neural network
        neuralNet.save("oddoreven.nnet");
    }
}

 

Link to comment
Share on other sites

Hello @Dietmar, i think you mixed up odd and even in some System.out.printf statements in the while-block.

I tried to make it a bit easier, only one double as input:

package multi;


import org.neuroph.core.data.DataSet;
import org.neuroph.core.data.DataSetRow;
import org.neuroph.nnet.MultiLayerPerceptron;
import org.neuroph.nnet.learning.BackPropagation;

import java.util.Scanner;

public class Multi1 {

    public static void main(String[] args) {
        // create MultiLayerPerceptron neural network
        MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(1, 4,4, 2);
        neuralNet.setLearningRule(new BackPropagation());

        // create training set
        DataSet trainingSet = new DataSet(1, 2);
        trainingSet.add(new DataSetRow(new double[]{0}, new double[]{1, 0})); //even
        trainingSet.add(new DataSetRow(new double[]{1}, new double[]{0, 1})); //odd
        trainingSet.add(new DataSetRow(new double[]{2}, new double[]{1, 0})); //even
        trainingSet.add(new DataSetRow(new double[]{4}, new double[]{1, 0})); //even
        trainingSet.add(new DataSetRow(new double[]{7}, new double[]{0, 1})); //odd
        trainingSet.add(new DataSetRow(new double[]{5}, new double[]{0, 1})); //odd
        trainingSet.add(new DataSetRow(new double[]{11}, new double[]{0, 1})); //odd
        trainingSet.add(new DataSetRow(new double[]{12}, new double[]{1, 0})); //even
        
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("Enter a number or 'exit' to quit:");
            String inputStr = scanner.nextLine();

            if (inputStr.equals("exit")) {
                break;
            }

         //  String inputStrArray = inputStr;
            double input = Double.parseDouble(inputStr);

            neuralNet.setInput(input);
            neuralNet.calculate();

            double[] output = neuralNet.getOutput();
            System.out.printf("Network prediction: %.2f even, %.2f odd %n", output[0], output[1]);

            if (output[0] > output[1]) {
                System.out.print("I think this is even. Is that correct? (y/n) ");
                String answer = scanner.nextLine();
                if (answer.equals("y")) {
                	trainingSet.add(new DataSetRow(new double[]{input}, new double[]{1, 0}));
                } else {
               	 // correcting as odd
                    trainingSet.add(new DataSetRow(new double[]{input}, new double[]{0, 1}));
                }
            } else {
                System.out.print("I think this is odd. Is that correct? (y/n) ");
                String answer = scanner.nextLine();
                if (answer.equals("y")) {
                   	trainingSet.add(new DataSetRow(new double[]{input}, new double[]{0, 1}));
                } else {
                 // correcting as even
                    trainingSet.add(new DataSetRow(new double[]{input}, new double[]{1, 0}));
                   }
            }
         // train neural network with updated training set
            neuralNet.learn(trainingSet);
        }

        // save trained neural network
        neuralNet.save("oddoreven.nnet");
    }
}

But then i have endless loops in neuralNet.learn and java running hot again...

Link to comment
Share on other sites

@Mark-XP

Yes, neuroph is unstable.

But the idea of neuroph is nice. So, I use it only for to test some concepts.

I make 0 0 2 as input with 3 Neurons, for to run not in the Normalizations problem via Sigmoid.

For me, the program works. And you can see, at which numbers of Neurons in Hidden Layers and at which numbers of Hidden Layers the program is overfitted. It then gives only answers as 0,00001 0,9999 even when this is wrong.

But two bad things I noticed: Here, no output file was generated, outputfile works before in my Prime program.

So I can use there a lot of Prime numbers for training. But the program is blind. I think, it is a fundamental problem of Neural Networks.

A lot of problems from Mathematics they cant work well on. Take knowledge in Mathematics as IQ test, then ChatGPT and all other Neural Networks have an IQ = 0.

And the even/odd program sometimes hangs up itself on the very first input

Dietmar

PS: Yesterday in the evening ChatGPT tolds me, that without mathematical formulas it can not decide, if a given number is a multiplier of 3.

So, no SkyNet in this century.

Link to comment
Share on other sites

Best, what you can find in Internet about Neural Network. Funny, this Network here "solves" any problem, because until now it has no Backpropagation. Means, it does not know, what it has to learn. And you can make a check, what happens to those two input values here. In my thinking, the output is any value between 0 and 1 for each Output Neuron. Should be equally(!) distributed Dietmar PS: I read, that a Neural Network can solve the same problems as a Turing Machine. But I think, that it is not true. I think, that it depends on at least 2 Hidden Layers. And for any tasks in Mathematics, Neural Networks are bad. They even cant find the Multipliers of 3 during looking for pattern in the integer Input Neurons values. I also make a try to find pattern in primes with a Neural Network. No pattern is found in primes by a Neural Network. They are blind. This is my definition of a real Intelligence: 1.) Find NEW patterns without any help. 2.) Can explain this new discovered pattern clear and easy to anyone. And sees the need of a prove for this pattern. Until now, no Ai can do this. So, SkyNet with Terminator has to wait for > 100 years.

 

Link to comment
Share on other sites

@Mark-XP

new Prime Number program.

This is nice

Dietmar

package primzahlerkennung;

import org.neuroph.core.data.DataSet;
import org.neuroph.core.data.DataSetRow;
import org.neuroph.nnet.MultiLayerPerceptron;
import org.neuroph.util.TransferFunctionType;

import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;

public class PrimzahlErkennung {

    public static void main(String[] args) {
        int inputSize = 101;
        
        int outputSize = 1;
        MultiLayerPerceptron neuralNetwork = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, inputSize, 10,10, outputSize);
        neuralNetwork.randomizeWeights(new Random());

        Scanner scanner = new Scanner(System.in);
        HashMap<Integer, Boolean> results = new HashMap<>(); // store recognized numbers and their predicted primality
        DataSet trainingSet = new DataSet(inputSize, outputSize); // create a training set for updating the neural network

        boolean quit = false; // flag to determine when to quit the program

        while (!quit) {
            System.out.println("Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):");
            String inputString = scanner.next();

            if (inputString.equalsIgnoreCase("q")) {
                quit = true; // set flag to quit the loop
                continue; // continue to next iteration
            } else if (inputString.equalsIgnoreCase("liste")) {
                System.out.println("Die getesteten Zahlen sind:");
                for (int num : results.keySet()) {
                    System.out.println(num);
                }
                continue; // continue to next iteration
            }

            int input;
            try {
                input = Integer.parseInt(inputString);
            } catch (NumberFormatException e) {
                System.out.println("Ungültige Eingabe. Bitte eine Zahl zwischen 1 und 100 eingeben:");
                continue; // continue to next iteration
            }

            while (input < 1 || input > 100) {
                System.out.println("Ungültige Eingabe. Bitte eine Zahl zwischen 1 und 100 eingeben:");
                input = scanner.nextInt();
            }

            if (results.containsKey(input)) {
                boolean isPrime = results.get(input);
                System.out.println("Ich denke, dass die eingegebene Zahl " + (isPrime ? "eine Primzahl ist." : "keine Primzahl ist."));
            } else {
                double[] inputValues = new double[101];
                for (int i = 0; i <= 100; i++) {
                    inputValues[i] = (i == input) ? 1 : 0;
                }

                neuralNetwork.setInput(inputValues);
                neuralNetwork.calculate();
                double[] output = neuralNetwork.getOutput();
                boolean isPrime = output[0] > 0.5;

                String proposition = isPrime ? "eine Primzahl ist." : "keine Primzahl ist.";
                System.out.println("Ich denke, dass die eingegebene Zahl " + proposition);

                System.out.println("Ist " + input + " eine Primzahl? (y/n):");
                String feedback = scanner.next();
                while (!feedback.equalsIgnoreCase("y") && !feedback.equalsIgnoreCase("n")) {
                    System.out.println("Ungültige Eingabe. Bitte 'y' oder 'n' eingeben:");
                    feedback = scanner.next();
                }

               




if (feedback.equalsIgnoreCase("y")) {
trainingSet.add(new DataSetRow(inputValues, new double[]{1}));
results.put(input, true);
} else {
trainingSet.add(new DataSetRow(inputValues, new double[]{0}));
results.put(input, false);
}


            neuralNetwork.learn(trainingSet); // update neural network with new training set
        }
    }

    System.out.println("Vielen Dank für die Nutzung der Primzahl-Erkennungs-Anwendung. Auf Wiedersehen!");
    scanner.close();
}
}



run:
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
1
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 1 eine Primzahl? (y/n):
y
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
2
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 2 eine Primzahl? (y/n):
y
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
3
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 3 eine Primzahl? (y/n):
y
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
4
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 4 eine Primzahl? (y/n):
n
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
5
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 5 eine Primzahl? (y/n):
y
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
4
Ich denke, dass die eingegebene Zahl keine Primzahl ist.
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
6
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 6 eine Primzahl? (y/n):
n
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
7
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 7 eine Primzahl? (y/n):
y
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
8
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 8 eine Primzahl? (y/n):
n
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
8
Ich denke, dass die eingegebene Zahl keine Primzahl ist.
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
9
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 9 eine Primzahl? (y/n):
n
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
10
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 10 eine Primzahl? (y/n):
n
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
11
Ich denke, dass die eingegebene Zahl eine Primzahl ist.
Ist 11 eine Primzahl? (y/n):
y
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
12
Ich denke, dass die eingegebene Zahl keine Primzahl ist.
Ist 12 eine Primzahl? (y/n):
n
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
12
Ich denke, dass die eingegebene Zahl keine Primzahl ist.
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):
liste
Die getesteten Zahlen sind:
1
2
3
4
5
6
7
8
9
10
11
12
Bitte geben Sie eine Zahl zwischen 1 und 100 ein (oder 'q' zum Beenden oder 'liste' um die getesteten Zahlen anzuzeigen):

 

Link to comment
Share on other sites

Hello @Dietmar an a happy easter! Sorry but i don't see any learning curve here in regards of prime-recognition (see attatchment).

Just as you stated above

On 4/8/2023 at 11:09 AM, Dietmar said:

And for any tasks in Mathematics, Neural Networks are bad. They even cant find the Multipliers of 3 during looking for pattern in the integer Input Neurons values. I also make a try to find pattern in primes with a Neural Network. No pattern is found in primes by a Neural Network. They are blind.

This is my definition of a real Intelligence: 1.) Find NEW patterns without any help. 2.) Can explain this new discovered pattern clear and easy to anyone. And sees the need of a prove for this pattern. Until now, no Ai can do this. So, SkyNet with Terminator has to wait for > 100 years.

Primes1_Out.txt

Link to comment
Share on other sites

@Mark-XP

Yes. This I want to demonstrate first. Neural Networks are blind as much as possible in Mathematics.

Today I make next try. More help is impossible for Neural Network.

I give it 10 Input Neurons. In them I store numbers between 0 and 1023 in Binary form.

Only I decide, if a number is prime or not. From this information, it should learn. For example, when the last digit is a "1", it cant be a prime (only 2).

If this Network does not learn what primes are, then there is a brutal limitation in the "intelligence" of Neural Networks

Dietmar

Link to comment
Share on other sites

@Mark-XP

I think, this is nearly best, what Neural Networks can offer for to find primes

Dietmar

 

package bine ;

import org.neuroph.core.NeuralNetwork;
import org.neuroph.core.data.DataSet;
import org.neuroph.core.data.DataSetRow;
import org.neuroph.nnet.MultiLayerPerceptron;
import org.neuroph.util.TransferFunctionType;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class Bine {

    private static final String PRIME_FILE_PATH = "prime_numbers.txt";
    private static final String NOT_PRIME_FILE_PATH = "not_prime_numbers.txt";

    public static void main(String[] args) {

        // Create a multi-layer perceptron neural network with 10 input neurons, 10 hidden neurons, and 2 output neurons
        NeuralNetwork neuralNetwork = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, 10, 10, 2);

        // Create a training set to store input-output pairs for training the neural network
        DataSet trainingSet = new DataSet(10, 2);

        Scanner scanner = new Scanner(System.in);
        String inputStr;

        System.out.println("Prime Number Classifier");
        System.out.println("Enter a number between 0 and 1023 (or 'q' to quit): ");

        while (!(inputStr = scanner.nextLine()).equalsIgnoreCase("q")) {
            try {
                int input = Integer.parseInt(inputStr);

                // Convert the input number to binary representation
                String binaryInput = Integer.toBinaryString(input);
                binaryInput = String.format("%10s", binaryInput).replace(' ', '0');
                System.out.println("Input: " + input);
                System.out.println("Binary Input: " + binaryInput);

                // Convert the binary input to an array of double values
                double[] inputArray = new double[10];
                for (int i = 0; i < 10; i++) {
                    inputArray[i] = Character.getNumericValue(binaryInput.charAt(i));
                }

                // Use the trained neural network to make a prediction
                neuralNetwork.setInput(inputArray);
                neuralNetwork.calculate();
                double[] output = neuralNetwork.getOutput();
                System.out.println("Output: " + output[0] + " " + output[1]);

                // Display the prediction
                String prediction = output[0] > output[1] ? "Prime" : "Not Prime";
                System.out.println("Prediction: " + prediction);

                // Prompt for user input on whether the input number is actually prime or not
                System.out.print("Is it prime? (y/n): ");
                String isPrime = scanner.nextLine();
                if (isPrime.equalsIgnoreCase("y")) {
                    // Add the input-output pair to the training set as a prime number
                    DataSetRow trainingSetRow = new DataSetRow(inputArray, new double[]{1, 0});
                    trainingSet.add(trainingSetRow);
                    writeToFile(PRIME_FILE_PATH, input); // Write the prime number to prime_numbers.txt
                } else {
                    // Add the input-output pair to the training set as a non-prime number
                    DataSetRow trainingSetRow = new DataSetRow(inputArray, new double[]{0, 1});
trainingSet.add(trainingSetRow);
                    writeToFile(NOT_PRIME_FILE_PATH, input); // Write the non-prime number to not_prime_numbers.txt
                }

                // Train the neural network with the updated training set
                neuralNetwork.learn(trainingSet);
                System.out.println("Enter a number between 0 and 1023 (or 'q' to quit): ");
            } catch (NumberFormatException e) {
              




System.out.println("Invalid input. Please enter a valid number between 0 and 1023 (or 'q' to quit): ");
}
}


    // Save the trained neural network to a file
    neuralNetwork.save("prime_number_classifier.nnet");
    System.out.println("Neural network trained and saved successfully.");
}

private static void writeToFile(String filePath, int number) {
    try {
        FileWriter fileWriter = new FileWriter(filePath, true);
        fileWriter.write(number + "\n");
        fileWriter.close();
    } catch (IOException e) {
        System.out.println("Failed to write to file: " + e.getMessage());
    }
}
}

 

Link to comment
Share on other sites

@Mark-XP

After hard work today, I make this program. May be, it has found something common in Primes!

I make a hard train for this Network with the first 1000 primes.

And now, it gives some correct answers for small and BIG primes

Dietmar

package bine;

import org.neuroph.core.NeuralNetwork;
import org.neuroph.core.data.DataSet;
import org.neuroph.core.data.DataSetRow;
import org.neuroph.nnet.MultiLayerPerceptron;
import org.neuroph.util.TransferFunctionType;

import java.util.Scanner;

public class Bine {

    public static void main(String[] args) {

        // Generate and store the first 1000 prime numbers in an array
        int[] primeNumbers = generatePrimeNumbers(1000);

        // Create a multi-layer perceptron neural network with 10 input neurons, 10 hidden neurons, and 2 output neurons
        NeuralNetwork neuralNetwork = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, 20, 20, 20, 2);

        // Create a training set to store input-output pairs for training the neural network
        DataSet trainingSet = new DataSet(20, 2);

        
        
        
        
        Scanner scanner = new Scanner(System.in);
        String inputStr;

        System.out.println("Prime Number Classifier");
        System.out.println("Enter a number between 0 and 1048575 (or 'q' to quit): ");

        while (!(inputStr = scanner.nextLine()).equalsIgnoreCase("q")) {
            try {
                int input = Integer.parseInt(inputStr);

                
                
                
                
                
                
                
                // Convert the input number to binary representation
                String binaryInput = Integer.toBinaryString(input);
                binaryInput = String.format("%20s", binaryInput).replace(' ', '0');
                System.out.println("Input: " + input);
                System.out.println("Binary Input: " + binaryInput);

                // Convert the binary input to an array of double values
double[] inputArray = new double[20];
for (int i = 0; i < binaryInput.length(); i++) {
    inputArray[i] = Character.getNumericValue(binaryInput.charAt(i));
}
// Fill remaining array elements with 0
for (int i = binaryInput.length(); i < 20; i++) {
    inputArray[i] = 0;
}

                // Use the trained neural network to make a prediction
                neuralNetwork.setInput(inputArray);
                neuralNetwork.calculate();
                double[] output = neuralNetwork.getOutput();
                System.out.println("Output: " + output[0] + " " + output[1]);

                // Display the prediction
                String prediction = output[0] > output[1] ? "Prime" : "Not Prime";
                System.out.println("Prediction: " + prediction);

                // Prompt for user input on whether the input number is actually prime or not
                System.out.print("Is it prime? (y/n): ");
                String isPrime = scanner.nextLine();
                if (isPrime.equalsIgnoreCase("y")) {
                    // Add the input-output pair to the training set as a prime number
                    DataSetRow trainingSetRow = new DataSetRow(inputArray, new double[]{1, 0});
                    trainingSet.add(trainingSetRow);
                } else {
                    // Add the input-output pair to the training set as a non-prime number
                    DataSetRow trainingSetRow = new DataSetRow(inputArray, new double[]{0, 1});
                    trainingSet.add(trainingSetRow);
                }

                // Train the neural network with the updated training set
                neuralNetwork.learn(trainingSet);
                System.out.println("Enter a number between 0 and 1048575 (or 'q' to quit): ");
            } catch (NumberFormatException e) {
                System.out.println("Invalid input. Please enter a valid number between 0 and 1048575 (or 'q' to quit): ");
            }
        }

        // Save the trained neural network to a file
       




        neuralNetwork.save("trained_neural_network.nnet");
        System.out.println("Trained neural network saved to file: trained_neural_network.nnet");

        System.out.println("Program terminated.");
    }

    /**
     * Generates an array of prime numbers up to a specified limit.
     *
     * @param limit The upper limit for prime numbers generation.
     * @return An array of prime numbers.
     */
    private static int[] generatePrimeNumbers(int limit) {
        int[] primes = new int[limit];
        primes[0] = 2;
        int count = 1;
        int num = 3;
        while (count < limit) {
            boolean isPrime = true;
            for (int i = 2; i <= Math.sqrt(num); i++) {
                if (num % i == 0) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                primes[count] = num;
                count++;
            }
            num += 2;
        }
        return primes;
    }
}



run:
Prime Number Classifier
Enter a number between 0 and 1048575 (or 'q' to quit): 
7919
Input: 7919
Binary Input: 00000001111011101111
Output: 0.5948178156516414 0.40897487989552267
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
7927
Input: 7927
Binary Input: 00000001111011110111
Output: 0.8982498273851647 0.09655551571874396
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
7907
Input: 7907
Binary Input: 00000001111011100011
Output: 0.9072894778480928 0.09231869767257159
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
7933
Input: 7933
Binary Input: 00000001111011111101
Output: 0.8989077406521399 0.09734911637879708
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
7937
Input: 7937
Binary Input: 00000001111100000001
Output: 0.9043350760591787 0.09614736963345205
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
1000
Input: 1000
Binary Input: 00000000001111101000
Output: 0.8899254682389591 0.10184634378010479
Prediction: Prime
Is it prime? (y/n): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
1000
Input: 1000
Binary Input: 00000000001111101000
Output: 0.1665975490914435 0.8151083424657837
Prediction: Not Prime
Is it prime? (y/n): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
2000
Input: 2000
Binary Input: 00000000011111010000
Output: 0.28750467198426777 0.6792374064713649
Prediction: Not Prime
Is it prime? (y/n): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
3000
Input: 3000
Binary Input: 00000000101110111000
Output: 0.20588325034563312 0.789819073942458
Prediction: Not Prime
Is it prime? (y/n): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
17389
Input: 17389
Binary Input: 00000100001111101101
Output: 0.12276962636373373 0.8798565969697876
Prediction: Not Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
17389
Input: 17389
Binary Input: 00000100001111101101
Output: 0.8110576316091068 0.2032560154260368
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
17393
Input: 17393
Binary Input: 00000100001111110001
Output: 0.43852962740457774 0.5431182165605312
Prediction: Not Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
17393
Input: 17393
Binary Input: 00000100001111110001
Output: 0.8034172912800364 0.20070059184113184
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
104723
Input: 104723
Binary Input: 00011001100100010011
Output: 0.9766085585945041 0.022881199994895813
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
104724
Input: 104724
Binary Input: 00011001100100010100
Output: 0.9411592225420404 0.05804579497623357
Prediction: Prime
Is it prime? (y/n): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
104724
Input: 104724
Binary Input: 00011001100100010100
Output: 0.21484292674011074 0.7599731192129849
Prediction: Not Prime
Is it prime? (y/n): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
17401
Input: 17401
Binary Input: 00000100001111111001
Output: 0.8248729136862214 0.19731821352791543
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
17402
Input: 17402
Binary Input: 00000100001111111010
Output: 0.25042646141880837 0.7694665916822424
Prediction: Not Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
17
Input: 17
Binary Input: 00000000000000010001
Output: 0.9147609290513441 0.07336348559716502
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
5
Input: 5
Binary Input: 00000000000000000101
Output: 0.9756104355881474 0.023320270188346374
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
1
Input: 1
Binary Input: 00000000000000000001
Output: 0.9532195348828819 0.04238520033787504
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
2
Input: 2
Binary Input: 00000000000000000010
Output: 0.6778584923010748 0.28103016635239125
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
0
Input: 0
Binary Input: 00000000000000000000
Output: 0.27281379291430097 0.6823362335383929
Prediction: Not Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
97
Input: 97
Binary Input: 00000000000001100001
Output: 0.995109554413573 0.005229627558735094
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
17401
Input: 17401
Binary Input: 00000100001111111001
Output: 0.9844012869157754 0.018723648793074754
Prediction: Prime
Is it prime? (y/n): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
17400
Input: 17400
Binary Input: 00000100001111111000
Output: 0.428308665635754 0.6069720955083222
Prediction: Not Prime
Is it prime? (y/n): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
17402
Input: 17402
Binary Input: 00000100001111111010
Output: 0.7872204761301146 0.240941722495304
Prediction: Prime
Is it prime? (y/n): n

 

 

Link to comment
Share on other sites

Even with 1000 of data, a Neural Network has BIG problems, to understand, if a given number is a Multiplier of 3 or not

Dietmar

package bine;

import org.neuroph.core.data.DataSet;
import org.neuroph.core.data.DataSetRow;
import org.neuroph.nnet.MultiLayerPerceptron;
import org.neuroph.util.TransferFunctionType;

import java.util.Scanner;

public class Bine {
    private static final int INPUT_SIZE = 20;
    private static final int OUTPUT_SIZE = 2;
    private static final String YES_LABEL = "y";
    private static final String NO_LABEL = "n";

    public static void main(String[] args) {
        int[] multiplesOfThree = generateMultiplesOfThree(1000);

        // Create training set
        DataSet trainingSet = new DataSet(INPUT_SIZE, OUTPUT_SIZE);

        for (int i = 0; i < INPUT_SIZE; i++) {
            String binaryInput = padZeros(Integer.toBinaryString(multiplesOfThree[i]));
            double[] inputArray = convertToDoubleArray(binaryInput);
            double[] outputArray = {1, 0}; // default output is "yes" as all multiples of 3 are "yes"

            // Add training set row
            DataSetRow trainingSetRow = new DataSetRow(inputArray, outputArray);
            trainingSet.add(trainingSetRow);
        }

        // Create neural network
        MultiLayerPerceptron neuralNetwork = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, INPUT_SIZE, 20,20,20, OUTPUT_SIZE);
        neuralNetwork.learn(trainingSet);

        System.out.println("Multiplier of 3 Classifier");
        System.out.println("Enter a number between 0 and 1048575 (or 'q' to quit): ");
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {
            String input = scanner.nextLine();

            if (input.equalsIgnoreCase("q")) {
                break;
            }

            try {
                int number = Integer.parseInt(input);
                String binaryInput = padZeros(Integer.toBinaryString(number));
                double[] inputArray = convertToDoubleArray(binaryInput);

                neuralNetwork.setInput(inputArray);
                neuralNetwork.calculate();
                double[] outputArray = neuralNetwork.getOutput();
                String prediction = outputArray[0] > outputArray[1] ? YES_LABEL : NO_LABEL;
                System.out.println("Input: " + number);
                System.out.println("Binary Input: " + binaryInput);
                System.out.println("Output: " + outputArray[0] + " " + outputArray[1]);
                System.out.println("Prediction: " + prediction);
                System.out.print("Is " + number + " a multiplier of 3? (Enter 'yes' or 'no'): ");
                String actualLabel = scanner.nextLine().toLowerCase();

                // Update the training set with the actual label provided by the user
                double[] actualOutput = {0, 0};
                if (actualLabel.equals(YES_LABEL)) {
                    actualOutput[0] = 1;
                } else if (actualLabel.equals(NO_LABEL)) {
                    actualOutput[1] = 1;
                } else {
                    System.out.println("Invalid input. Please enter 'yes' or 'no'.");
                    continue;
                }

                trainingSet.add(new DataSetRow(inputArray, actualOutput));
                neuralNetwork.learn(trainingSet);

                System.out.println("Enter a number between 0 and 1048575 (or 'q' to quit): ");
            } catch (NumberFormatException e) {
                System.out.println("Invalid input. Please enter a valid number or 'q' to quit.");
            }
        }

        System.out.println("Exiting...");
    }

    private static int[] generateMultiplesOfThree(int count)




{
int[] multiples = new int[count];
for (int i = 0; i < count; i++) {
multiples[i] = i * 3;
}
return multiples;
}


private static String padZeros(String binaryString) {
    int padSize = INPUT_SIZE - binaryString.length();
    StringBuilder stringBuilder = new StringBuilder();
    for (int i = 0; i < padSize; i++) {
        stringBuilder.append("0");
    }
    stringBuilder.append(binaryString);
    return stringBuilder.toString();
}

private static double[] convertToDoubleArray(String binaryString) {
    double[] doubleArray = new double[binaryString.length()];
    for (int i = 0; i < binaryString.length(); i++) {
        doubleArray[i] = Double.parseDouble(String.valueOf(binaryString.charAt(i)));
    }
    return doubleArray;
}
}


run:
Multiplier of 3 Classifier
Enter a number between 0 and 1048575 (or 'q' to quit): 
0
Input: 0
Binary Input: 00000000000000000000
Output: 0.9100712334367754 0.09189905889860366
Prediction: y
Is 0 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
1
Input: 1
Binary Input: 00000000000000000001
Output: 0.9199956082571938 0.08266183058418203
Prediction: y
Is 1 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
1
Input: 1
Binary Input: 00000000000000000001
Output: 0.3337935010084839 0.6956108756117879
Prediction: n
Is 1 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
2
Input: 2
Binary Input: 00000000000000000010
Output: 0.9796338688814583 0.01525102284028862
Prediction: y
Is 2 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
3
Input: 3
Binary Input: 00000000000000000011
Output: 0.8238038968341835 0.17195128283031036
Prediction: y
Is 3 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
4
Input: 4
Binary Input: 00000000000000000100
Output: 0.9822951015347582 0.016470688185103253
Prediction: y
Is 4 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
5
Input: 5
Binary Input: 00000000000000000101
Output: 0.001050534727176706 0.9987121963998032
Prediction: n
Is 5 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
6
Input: 6
Binary Input: 00000000000000000110
Output: 0.839733051941253 0.163455141466426
Prediction: y
Is 6 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
7
Input: 7
Binary Input: 00000000000000000111
Output: 0.9422758274098985 0.06609906216555786
Prediction: y
Is 7 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
7
Input: 7
Binary Input: 00000000000000000111
Output: 0.1353661273127858 0.8479548991014965
Prediction: n
Is 7 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
8
Input: 8
Binary Input: 00000000000000001000
Output: 0.9927541716568125 0.009574226211425924
Prediction: y
Is 8 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
9
Input: 9
Binary Input: 00000000000000001001
Output: 0.974322603589938 0.02800165260840982
Prediction: y
Is 9 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
10
Input: 10
Binary Input: 00000000000000001010
Output: 0.003214245556632083 0.9974629414600507
Prediction: n
Is 10 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
11
Input: 11
Binary Input: 00000000000000001011
Output: 0.9538310639638198 0.049426501469771754
Prediction: y
Is 11 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
12
Input: 12
Binary Input: 00000000000000001100
Output: 0.9305042545208035 0.06093073932423666
Prediction: y
Is 12 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
13
Input: 13
Binary Input: 00000000000000001101
Output: 0.031104660029981284 0.967017516492239
Prediction: n
Is 13 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
14
Input: 14
Binary Input: 00000000000000001110
Output: 0.7584994116416115 0.23504684198291034
Prediction: y
Is 14 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
15
Input: 15
Binary Input: 00000000000000001111
Output: 0.8893613013013443 0.10890092946550244
Prediction: y
Is 15 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
16
Input: 16
Binary Input: 00000000000000010000
Output: 0.9916013043686388 0.008933010479803792
Prediction: y
Is 16 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
16
Input: 16
Binary Input: 00000000000000010000
Output: 0.35652098277360933 0.5526217281816489
Prediction: n
Is 16 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
17
Input: 17
Binary Input: 00000000000000010001
Output: 0.48630373725336073 0.5024843160185609
Prediction: n
Is 17 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
18
Input: 18
Binary Input: 00000000000000010010
Output: 0.9261826400724928 0.08958856435275989
Prediction: y
Is 18 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
19
Input: 19
Binary Input: 00000000000000010011
Output: 0.8620823020896886 0.163939531835348
Prediction: y
Is 19 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
20
Input: 20
Binary Input: 00000000000000010100
Output: 0.3351872280028068 0.6478808694200352
Prediction: n
Is 20 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
21
Input: 21
Binary Input: 00000000000000010101
Output: 0.7904427907287952 0.23576855466040111
Prediction: y
Is 21 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
22
Input: 22
Binary Input: 00000000000000010110
Output: 0.8170613517651504 0.20645015903126232
Prediction: y
Is 22 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
22
Input: 22
Binary Input: 00000000000000010110
Output: 0.22787401245457897 0.7441538560501173
Prediction: n
Is 22 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
23
Input: 23
Binary Input: 00000000000000010111
Output: 0.1339085286870765 0.8469448145925296
Prediction: n
Is 23 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
24
Input: 24
Binary Input: 00000000000000011000
Output: 0.8874061486258907 0.11497359351313596
Prediction: y
Is 24 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
25
Input: 25
Binary Input: 00000000000000011001
Output: 0.15755045584912372 0.8091783496834866
Prediction: n
Is 25 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
26
Input: 26
Binary Input: 00000000000000011010
Output: 0.03925126560699438 0.9715306109005235
Prediction: n
Is 26 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
27
Input: 27
Binary Input: 00000000000000011011
Output: 0.9559097639458656 0.05095360729159218
Prediction: y
Is 27 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
28
Input: 28
Binary Input: 00000000000000011100
Output: 0.45200690232813 0.5357941076078971
Prediction: n
Is 28 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
29
Input: 29
Binary Input: 00000000000000011101
Output: 0.12687961662377373 0.8584768579494491
Prediction: n
Is 29 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
30
Input: 30
Binary Input: 00000000000000011110
Output: 0.9224716526513721 0.0858270690719063
Prediction: y
Is 30 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
31
Input: 31
Binary Input: 00000000000000011111
Output: 0.49774812656404066 0.5025265565285598
Prediction: n
Is 31 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
32
Input: 32
Binary Input: 00000000000000100000
Output: 0.9359186285571272 0.08614560640060934
Prediction: y
Is 32 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
33
Input: 33
Binary Input: 00000000000000100001
Output: 0.9603041500915385 0.047485514235209095
Prediction: y
Is 33 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
34
Input: 34
Binary Input: 00000000000000100010
Output: 0.9239103288560171 0.07854883505186429
Prediction: y
Is 34 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
34
Input: 34
Binary Input: 00000000000000100010
Output: 0.19781752980316994 0.7858325722826717
Prediction: n
Is 34 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
35
Input: 35
Binary Input: 00000000000000100011
Output: 0.28770592455358457 0.7156871726928946
Prediction: n
Is 35 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
36
Input: 36
Binary Input: 00000000000000100100
Output: 0.9236156143759313 0.08846758473491223
Prediction: y
Is 36 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
37
Input: 37
Binary Input: 00000000000000100101
Output: 0.23446107024438664 0.8250653732662508
Prediction: n
Is 37 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
38
Input: 38
Binary Input: 00000000000000100110
Output: 0.051438331817040515 0.9437063918873614
Prediction: n
Is 38 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
39
Input: 39
Binary Input: 00000000000000100111
Output: 0.9762792364704111 0.028936103018579736
Prediction: y
Is 39 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
40
Input: 40
Binary Input: 00000000000000101000
Output: 0.1432548644088406 0.8355017022220126
Prediction: n
Is 40 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
41
Input: 41
Binary Input: 00000000000000101001
Output: 0.17347697719232452 0.8178385982490991
Prediction: n
Is 41 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
42
Input: 42
Binary Input: 00000000000000101010
Output: 0.9392881001757781 0.05788579216431461
Prediction: y
Is 42 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
43
Input: 43
Binary Input: 00000000000000101011
Output: 0.29258802916394 0.6875516289760418
Prediction: n
Is 43 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
44
Input: 44
Binary Input: 00000000000000101100
Output: 0.035499036517101325 0.9602535581278479
Prediction: n
Is 44 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
45
Input: 45
Binary Input: 00000000000000101101
Output: 0.9760318272683148 0.029261784923761934
Prediction: y
Is 45 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
46
Input: 46
Binary Input: 00000000000000101110
Output: 0.040685573799271714 0.9537492032509323
Prediction: n
Is 46 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
47
Input: 47
Binary Input: 00000000000000101111
Output: 0.11327853160003044 0.883969734357003
Prediction: n
Is 47 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
48
Input: 48
Binary Input: 00000000000000110000
Output: 0.6700494087039256 0.3574408802320197
Prediction: y
Is 48 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
49
Input: 49
Binary Input: 00000000000000110001
Output: 0.6253087315720828 0.4108396596288409
Prediction: y
Is 49 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
49
Input: 49
Binary Input: 00000000000000110001
Output: 0.12875234268833807 0.8717714013421612
Prediction: n
Is 49 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
50
Input: 50
Binary Input: 00000000000000110010
Output: 0.6459714506419655 0.36180099233049323
Prediction: y
Is 50 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
51
Input: 51
Binary Input: 00000000000000110011
Output: 0.16347818046005394 0.8312737613229517
Prediction: n
Is 51 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
51
Input: 51
Binary Input: 00000000000000110011
Output: 0.9160031128700459 0.09356523417958804
Prediction: y
Is 51 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
52
Input: 52
Binary Input: 00000000000000110100
Output: 0.8718983144433389 0.14481795320289975
Prediction: y
Is 52 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
53
Input: 53
Binary Input: 00000000000000110101
Output: 0.03712895375449015 0.9615538502928446
Prediction: n
Is 53 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
54
Input: 54
Binary Input: 00000000000000110110
Output: 0.34792203463078675 0.6476806112182635
Prediction: n
Is 54 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
54
Input: 54
Binary Input: 00000000000000110110
Output: 0.9337528194925984 0.0734701302415432
Prediction: y
Is 54 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
55
Input: 55
Binary Input: 00000000000000110111
Output: 0.8401025073226862 0.17624247029627635
Prediction: y
Is 55 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
56
Input: 56
Binary Input: 00000000000000111000
Output: 0.4376921127204153 0.5288647412543214
Prediction: n
Is 56 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
57
Input: 57
Binary Input: 00000000000000111001
Output: 0.35784229098837006 0.639184495428392
Prediction: n
Is 57 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
58
Input: 58
Binary Input: 00000000000000111010
Output: 0.3275547600857225 0.6365719335860395
Prediction: n
Is 58 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
59
Input: 59
Binary Input: 00000000000000111011
Output: 0.5212998937295816 0.46370447443571056
Prediction: y
Is 59 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
60
Input: 60
Binary Input: 00000000000000111100
Output: 0.49494094163395463 0.515164077408551
Prediction: n
Is 60 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
61
Input: 61
Binary Input: 00000000000000111101
Output: 0.12983194965647718 0.8751486276898385
Prediction: n
Is 61 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
62
Input: 62
Binary Input: 00000000000000111110
Output: 0.1354627962453532 0.8508357725879964
Prediction: n
Is 62 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
63
Input: 63
Binary Input: 00000000000000111111
Output: 0.8580775772153315 0.1548940737326462
Prediction: y
Is 63 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
64
Input: 64
Binary Input: 00000000000001000000
Output: 0.6689906035307732 0.28523305336324334
Prediction: y
Is 64 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
64
Input: 64
Binary Input: 00000000000001000000
Output: 0.09024607528015935 0.8855227387349809
Prediction: n
Is 64 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
65
Input: 65
Binary Input: 00000000000001000001
Output: 0.0014028229343147122 0.9979661620811804
Prediction: n
Is 65 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
66
Input: 66
Binary Input: 00000000000001000010
Output: 0.071277062085114 0.9316594962445945
Prediction: n
Is 66 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
66
Input: 66
Binary Input: 00000000000001000010
Output: 0.7639158273279077 0.23643134493428689
Prediction: y
Is 66 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
67
Input: 67
Binary Input: 00000000000001000011
Output: 0.32931192178485597 0.6249807256144181
Prediction: n
Is 67 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
68
Input: 68
Binary Input: 00000000000001000100
Output: 0.0015278707240816741 0.997851621652362
Prediction: n
Is 68 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
69
Input: 69
Binary Input: 00000000000001000101
Output: 0.004642258291229637 0.9960405384602112
Prediction: n
Is 69 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
69
Input: 69
Binary Input: 00000000000001000101
Output: 0.05291105727425499 0.9650080807586029
Prediction: n
Is 69 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
69
Input: 69
Binary Input: 00000000000001000101
Output: 0.6308213984022305 0.3873806565698832
Prediction: y
Is 69 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
70
Input: 70
Binary Input: 00000000000001000110
Output: 0.11363700854908698 0.8758080479624577
Prediction: n
Is 70 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
400000
Input: 400000
Binary Input: 01100001101010000000
Output: 0.4832064917528005 0.4811556109134067
Prediction: y
Is 400000 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
400001
Input: 400001
Binary Input: 01100001101010000001
Output: 0.0036193370555938245 0.9946507642044927
Prediction: n
Is 400001 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
400002
Input: 400002
Binary Input: 01100001101010000010
Output: 0.7446095173248048 0.23528279571892657
Prediction: y
Is 400002 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
400003
Input: 400003
Binary Input: 01100001101010000011
Output: 0.05894585339564528 0.9372440386296929
Prediction: n
Is 400003 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
400004
Input: 400004
Binary Input: 01100001101010000100
Output: 0.004140042080300098 0.9940283829617482
Prediction: n
Is 400004 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
400005
Input: 400005
Binary Input: 01100001101010000101
Output: 0.14724910196008825 0.8341763303972134
Prediction: n
Is 400005 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
400006
Input: 400006
Binary Input: 01100001101010000110
Output: 0.04719732699802866 0.9523921755461555
Prediction: n
Is 400006 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
400007
Input: 400007
Binary Input: 01100001101010000111
Output: 0.08964804980246287 0.8901720297744107
Prediction: n
Is 400007 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
400008
Input: 400008
Binary Input: 01100001101010001000
Output: 0.8926745955166815 0.09599591040932905
Prediction: y
Is 400008 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
400009
Input: 400009
Binary Input: 01100001101010001001
Output: 0.08320620848618612 0.9122336408276123
Prediction: n
Is 400009 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
900000
Input: 900000
Binary Input: 11011011101110100000
Output: 0.006660058988903214 0.9932227829445179
Prediction: n
Is 900000 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
900000
Input: 900000
Binary Input: 11011011101110100000
Output: 0.9947426011094758 0.005870490518981226
Prediction: y
Is 900000 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
900001
Input: 900001
Binary Input: 11011011101110100001
Output: 0.9945251541678684 0.006566273958997189
Prediction: y
Is 900001 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
900002
Input: 900002
Binary Input: 11011011101110100010
Output: 0.005198558641792289 0.9947649705403714
Prediction: n
Is 900002 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
900003
Input: 900003
Binary Input: 11011011101110100011
Output: 0.05779073219580073 0.9457906343599145
Prediction: n
Is 900003 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
900003
Input: 900003
Binary Input: 11011011101110100011
Output: 0.9899582052817851 0.011386698089575481
Prediction: y
Is 900003 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
900004
Input: 900004
Binary Input: 11011011101110100100
Output: 0.16576791749479478 0.8626139713512534
Prediction: n
Is 900004 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
900005
Input: 900005
Binary Input: 11011011101110100101
Output: 0.9514640691115387 0.05356315464296517
Prediction: y
Is 900005 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
900006
Input: 900006
Binary Input: 11011011101110100110
Output: 0.9553406282490174 0.052071081041834284
Prediction: y
Is 900006 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
900007
Input: 900007
Binary Input: 11011011101110100111
Output: 0.019674569372234017 0.9831333704771245
Prediction: n
Is 900007 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
900008
Input: 900008
Binary Input: 11011011101110101000
Output: 0.0757328021477335 0.9238494722865295
Prediction: n
Is 900008 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
900009
Input: 900009
Binary Input: 11011011101110101001
Output: 0.9441941605886921 0.0629870673122703
Prediction: y
Is 900009 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 
1000000
Input: 1000000
Binary Input: 11110100001001000000
Output: 0.0035819148391924077 0.996487210875288
Prediction: n
Is 1000000 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
1000001
Input: 1000001
Binary Input: 11110100001001000001
Output: 0.9204871456593733 0.08389017722343028
Prediction: y
Is 1000001 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
1000001
Input: 1000001
Binary Input: 11110100001001000001
Output: 0.31750751148746975 0.6944189104683715
Prediction: n
Is 1000001 a multiplier of 3? (Enter 'yes' or 'no'): n
Enter a number between 0 and 1048575 (or 'q' to quit): 
1000002
Input: 1000002
Binary Input: 11110100001001000010
Output: 0.5387750063738229 0.4577310559747821
Prediction: y
Is 1000002 a multiplier of 3? (Enter 'yes' or 'no'): y
Enter a number between 0 and 1048575 (or 'q' to quit): 

 

Edited by Dietmar
Link to comment
Share on other sites

@Mark-XP

Here is a new, really nice program for to find the Multipliers of 3.:cheerleader::cheerleader::cheerleader:

It uses ONLY the Java Standard Bibliothek. So it runs on any compi.

In detail you can check and test via this program, how a Neural Network works.

And you see also, what happens, when you give to the program a number, which it was not trained for.

Oh...looks not so good for SkyNet with Terminator

Dietmar

package multiof3;


import java.util.Arrays;
import java.util.Random;

import java.util.Random;

public class Multiof3 {
    private final int numInputNodes = 3;
    private final int numHiddenNodes = 2;
    private final int numOutputNodes = 1;
    private final double learningRate = 0.1;
    private final int numEpochs = 200000;
    private final double errorThreshold = 0.01;
    
    private double[][] inputToHiddenWeights;
    private double[][] hiddenToOutputWeights;
    private double[] hiddenBiases;
    private double[] outputBiases;
    
    public Multiof3() {
        Random random = new Random();
        inputToHiddenWeights = new double[numInputNodes][numHiddenNodes];
        hiddenToOutputWeights = new double[numHiddenNodes][numOutputNodes];
        hiddenBiases = new double[numHiddenNodes];
        outputBiases = new double[numOutputNodes];
        
        for (int i = 0; i < numInputNodes; i++) {
            for (int j = 0; j < numHiddenNodes; j++) {
                inputToHiddenWeights[i][j] = random.nextDouble() - 0.5;
            }
        }
        
        for (int i = 0; i < numHiddenNodes; i++) {
            for (int j = 0; j < numOutputNodes; j++) {
                hiddenToOutputWeights[i][j] = random.nextDouble() - 0.5;
            }
            hiddenBiases[i] = random.nextDouble() - 0.5;
        }
        
        for (int i = 0; i < numOutputNodes; i++) {
            outputBiases[i] = random.nextDouble() - 0.5;
        }
    }
    
    public double sigmoid(double x) {
        return 1.0 / (1.0 + Math.exp(-x));
    }
    
    public double sigmoidDerivative(double x) {
        return sigmoid(x) * (1 - sigmoid(x));
    }
    
    public void train(double[][] trainingInputs, double[] trainingTargets) {
        for (int epoch = 1; epoch <= numEpochs; epoch++) {
            double totalError = 0.0;
            for (int i = 0; i < trainingInputs.length; i++) {
                double[] input = trainingInputs[i];
                double target = trainingTargets[i];
                
                // Forward propagation
                double[] hiddenOutputs = new double[numHiddenNodes];
                for (int j = 0; j < numHiddenNodes; j++) {
                    double weightedSum = 0.0;
                    for (int k = 0; k < numInputNodes; k++) {
                        weightedSum += inputToHiddenWeights[k][j] * input[k];
                    }
                    hiddenOutputs[j] = sigmoid(weightedSum + hiddenBiases[j]);
                }
                
                double output = 0.0;
                for (int j = 0; j < numOutputNodes; j++) {
                    double weightedSum = 0.0;
                    for (int k = 0; k < numHiddenNodes; k++) {
                        weightedSum += hiddenToOutputWeights[k][j] * hiddenOutputs[k];
                    }
                    output = sigmoid(weightedSum + outputBiases[j]);
                }
                
                // Backward propagation
                double outputError = 0.5 * Math.pow(output - target, 2); // Mean squared error
                totalError += outputError;
                
                double outputDelta = (output - target) * sigmoidDerivative(output);
for (int j = 0; j < numOutputNodes; j++) {
    outputBiases[j] -= learningRate * outputDelta;
    for (int k = 0; k < numHiddenNodes; k++) {
        hiddenToOutputWeights[k][j] -= learningRate * outputDelta * hiddenOutputs[k];
    }
}


            double[] hiddenDeltas = new double[numHiddenNodes];
            for (int j = 0; j < numHiddenNodes; j++) {
                double weightedSum = 0.0;
                for (int k = 0; k < numOutputNodes; k++) {
                    weightedSum += hiddenToOutputWeights[j][k] * outputDelta;
                }
                hiddenDeltas[j] = sigmoidDerivative(hiddenOutputs[j]) * weightedSum;
            }
            
            for (int j = 0; j < numHiddenNodes; j++) {
                hiddenBiases[j] -= learningRate * hiddenDeltas[j];
                for (int k = 0; k < numInputNodes; k++) {
                    inputToHiddenWeights[k][j] -= learningRate * hiddenDeltas[j] * input[k];
                }
            }
        }
        
        totalError /= trainingInputs.length;
        
        if (epoch % 1000 == 0) {
            System.out.println("Epoch: " + epoch + ", Error: " + totalError);
        }
        
        if (totalError <= errorThreshold) {
            System.out.println("Training complete. Total error: " + totalError);
            break;
        }
    }
}

public double predict(double[] input) {
    double[] hiddenOutputs = new double[numHiddenNodes];
    for (int j = 0; j < numHiddenNodes; j++) {
        double weightedSum = 0.0;
        for (int k = 0; k < numInputNodes; k++) {
            weightedSum += inputToHiddenWeights[k][j] * input[k];
        }
        hiddenOutputs[j] = sigmoid(weightedSum + hiddenBiases[j]);
    }
    
    double output = 0.0;
    for (int j = 0; j < numOutputNodes; j++) {
        double weightedSum = 0.0;
        for (int k = 0; k < numHiddenNodes; k++) {
            weightedSum += hiddenToOutputWeights[k][j] * hiddenOutputs[k];
        }
        output = sigmoid(weightedSum + outputBiases[j]);
    }
    
    return output;
}

public static void main(String[] args) {
    // Example usage of the neural network
    double[][] trainingInputs = {{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 1}, {1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1}};
    double[] trainingTargets = {1, 0, 0, 1, 0, 0, 1, 0 };
    
    Multiof3 nn = new Multiof3();
    nn.train(trainingInputs, trainingTargets);
    
    System.out.println("Prediction for [0, 0, 0]: " + nn.predict(new double[]{0, 0, 0}));
    System.out.println("Prediction for [0, 0, 1]: " + nn.predict(new double[]{0, 0, 1}));
    System.out.println("Prediction for [0, 1, 0]: " + nn.predict(new double[]{0, 1, 0}));
    System.out.println("Prediction for [0, 1, 1]: " + nn.predict(new double[]{0, 1, 1}));

    System.out.println("Prediction for [1, 0, 0]: " + nn.predict(new double[]{1, 0, 0}));
    System.out.println("Prediction for [1, 0, 1]: " + nn.predict(new double[]{1, 0, 1}));
    System.out.println("Prediction for [1, 1, 0]: " + nn.predict(new double[]{1, 1, 0}));
    System.out.println("Prediction for [1, 1, 1]: " + nn.predict(new double[]{1, 1, 1}));
}


}



 

Link to comment
Share on other sites

Hi,

here is a new program, for to learn the multipliers of 3. This program uses ReLu everywhere.

It learns the Multipliers from 3 from 0..255 numbers converted to Binary form.

Now I understand, how Neural Network learns and make some "predictions"

Dietmar

 

package multiof3;

import java.util.Arrays;
import java.util.Random;

public class Multiof3 {
    private final int numInputNodes = 8;
    private final int numHiddenNodes = 26;
    private final int numOutputNodes = 1;
    private final double learningRate = 0.01;
    private final int numEpochs = 100000;
    private final double errorThreshold = 0.001;

    private double[][] inputToHiddenWeights;
    private double[][] hiddenToOutputWeights;
    private double[] hiddenBiases;
    private double[] outputBiases;

    public Multiof3() {
        Random random = new Random();
        inputToHiddenWeights = new double[numInputNodes][numHiddenNodes];
        hiddenToOutputWeights = new double[numHiddenNodes][numOutputNodes];
        hiddenBiases = new double[numHiddenNodes];
        outputBiases = new double[numOutputNodes];

        for (int i = 0; i < numInputNodes; i++) {
            for (int j = 0; j < numHiddenNodes; j++) {
                inputToHiddenWeights[i][j] = random.nextDouble() - 0.5;
            }
        }

        for (int i = 0; i < numHiddenNodes; i++) {
            for (int j = 0; j < numOutputNodes; j++) {
                hiddenToOutputWeights[i][j] = random.nextDouble() - 0.5;
            }
            hiddenBiases[i] = random.nextDouble() - 0.5;
        }

        for (int i = 0; i < numOutputNodes; i++) {
            outputBiases[i] = random.nextDouble() - 0.5;
        }
    }

    public double relu(double x) {
        return Math.max(0, x);
    }

    public double reluDerivative(double x) {
        return x > 0 ? 1 : 0;
    }

    public void train(double[][] trainingInputs, double[] trainingTargets) {
        for (int epoch = 1; epoch <= numEpochs; epoch++) {
            double totalError = 0.0;
            for (int i = 0; i < trainingInputs.length; i++) {
                double[] input = trainingInputs[i];
                double target = trainingTargets[i];

                // Forward propagation
                double[] hiddenOutputs = new double[numHiddenNodes];
                for (int j = 0; j < numHiddenNodes; j++) {
                    double weightedSum = 0.0;
                    for (int k = 0; k < numInputNodes; k++) {
                        weightedSum += inputToHiddenWeights[k][j] * input[k];
                    }
                    hiddenOutputs[j] = relu(weightedSum + hiddenBiases[j]);
                }

                double output = 0.0;
                for (int j = 0; j < numOutputNodes; j++) {
                    double weightedSum = 0.0;
                    for (int k = 0; k < numHiddenNodes; k++) {
                        weightedSum += hiddenToOutputWeights[k][j] * hiddenOutputs[k];
                    }
                    output = relu(weightedSum + outputBiases[j]);
                }

                
// Backward propagation
double outputErrorGradient = (output - target) * reluDerivative(output);
for (int j = 0; j < numHiddenNodes; j++) {
double hiddenErrorGradient = outputErrorGradient * hiddenToOutputWeights[j][0] * reluDerivative(hiddenOutputs[j]);
for (int k = 0; k < numInputNodes; k++) {
inputToHiddenWeights[k][j] -= learningRate * input[k] * hiddenErrorGradient;
}
hiddenBiases[j] -= learningRate * hiddenErrorGradient;
}
hiddenToOutputWeights[0][0] -= learningRate * hiddenOutputs[0] * outputErrorGradient;
outputBiases[0] -= learningRate * outputErrorGradient;


            // Update total error
            totalError += Math.pow(output - target, 2);
        }

        // Calculate mean error and check for convergence
        double meanError = totalError / trainingInputs.length;
        if (meanError < errorThreshold) {
            System.out.println("Training complete. Mean error: " + meanError);
            break;
        } else if (epoch % 10000 == 0) {
            System.out.println("Epoch " + epoch + ". Mean error: " + meanError);
        }
    }
}

public double predict(double[] input) {
    double[] hiddenOutputs = new double[numHiddenNodes];
    for (int j = 0; j < numHiddenNodes; j++) {
        double weightedSum = 0.0;
        for (int k = 0; k < numInputNodes; k++) {
            weightedSum += inputToHiddenWeights[k][j] * input[k];
        }
        hiddenOutputs[j] = relu(weightedSum + hiddenBiases[j]);
    }

    double output = 0.0;
    for (int j = 0; j < numOutputNodes; j++) {
        double weightedSum = 0.0;
        for (int k = 0; k < numHiddenNodes; k++) {
            weightedSum += hiddenToOutputWeights[k][j] * hiddenOutputs[k];
        }
        output = relu(weightedSum + outputBiases[j]);
    }

    return output;
}






public static void main(String[] args) {
    // Example usage of the neural network
    double[][] trainingInputs = 
{{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 0, 1, 1},
{0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 1},
{0, 0, 0, 0, 0, 1, 1, 0},
{0, 0, 0, 0, 0, 1, 1, 1},
{0, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 1},
{0, 0, 0, 0, 1, 0, 1, 0},
{0, 0, 0, 0, 1, 0, 1, 1},
{0, 0, 0, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 1, 0, 1},
{0, 0, 0, 0, 1, 1, 1, 0},
{0, 0, 0, 0, 1, 1, 1, 1},
{0, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 1},
{0, 0, 0, 1, 0, 0, 1, 0},
{0, 0, 0, 1, 0, 0, 1, 1},
{0, 0, 0, 1, 0, 1, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1},
{0, 0, 0, 1, 0, 1, 1, 0},
{0, 0, 0, 1, 0, 1, 1, 1},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 1},
{0, 0, 0, 1, 1, 0, 1, 0},
{0, 0, 0, 1, 1, 0, 1, 1},
{0, 0, 0, 1, 1, 1, 0, 0},  
{0, 0, 0, 1, 1, 1, 0, 1},
{0, 0, 0, 1, 1, 1, 1, 0},
{0, 0, 0, 1, 1, 1, 1, 1},
{0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 1},
{0, 0, 1, 0, 0, 0, 1, 0},
{0, 0, 1, 0, 0, 0, 1, 1},
{0, 0, 1, 0, 0, 1, 0, 0},
{0, 0, 1, 0, 0, 1, 0, 1},
{0, 0, 1, 0, 0, 1, 1, 0},
{0, 0, 1, 0, 0, 1, 1, 1},
{0, 0, 1, 0, 1, 0, 0, 0},
{0, 0, 1, 0, 1, 0, 0, 1},
{0, 0, 1, 0, 1, 0, 1, 0},
{0, 0, 1, 0, 1, 0, 1, 1},
{0, 0, 1, 0, 1, 1, 0, 0},
{0, 0, 1, 0, 1, 1, 0, 1},
{0, 0, 1, 0, 1, 1, 1, 0},
{0, 0, 1, 0, 1, 1, 1, 1},
{0, 0, 1, 1, 0, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 0, 1},
{0, 0, 1, 1, 0, 0, 1, 0},
{0, 0, 1, 1, 0, 0, 1, 1},
{0, 0, 1, 1, 0, 1, 0, 0},
{0, 0, 1, 1, 0, 1, 0, 1},
{0, 0, 1, 1, 0, 1, 1, 0},
{0, 0, 1, 1, 0, 1, 1, 1},
{0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0, 1},
{0, 0, 1, 1, 1, 0, 1, 0},
{0, 0, 1, 1, 1, 0, 1, 1},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 1},
{0, 0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 1},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 1},
{0, 1, 0, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 1, 0, 1},
{0, 1, 0, 0, 0, 1, 1, 0},
{0, 1, 0, 0, 0, 1, 1, 1},
{0, 1, 0, 0, 1, 0, 0, 0},
{0, 1, 0, 0, 1, 0, 0, 1},
{0, 1, 0, 0, 1, 0, 1, 0},
{0, 1, 0, 0, 1, 0, 1, 1},
{0, 1, 0, 0, 1, 1, 0, 0},
{0, 1, 0, 0, 1, 1, 0, 1},
{0, 1, 0, 0, 1, 1, 1, 0},
{0, 1, 0, 0, 1, 1, 1, 1},
{0, 1, 0, 1, 0, 0, 0, 0},
{0, 1, 0, 1, 0, 0, 0, 1},
{0, 1, 0, 1, 0, 0, 1, 0},
{0, 1, 0, 1, 0, 0, 1, 1},
{0, 1, 0, 1, 0, 1, 0, 0},
{0, 1, 0, 1, 0, 1, 0, 1},
{0, 1, 0, 1, 0, 1, 1, 0},
{0, 1, 0, 1, 0, 1, 1, 1},
{0, 1, 0, 1, 1, 0, 0, 0},
{0, 1, 0, 1, 1, 0, 0, 1},
{0, 1, 0, 1, 1, 0, 1, 0},
{0, 1, 0, 1, 1, 0, 1, 1},
{0, 1, 0, 1, 1, 1, 0, 0},
{0, 1, 0, 1, 1, 1, 0, 1},
{0, 1, 0, 1, 1, 1, 1, 0},
{0, 1, 0, 1, 1, 1, 1, 1},
{0, 1, 1, 0, 0, 0, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 1},
{0, 1, 1, 0, 0, 0, 1, 0},
{0, 1, 1, 0, 0, 0, 1, 1},
{0, 1, 1, 0, 0, 1, 0, 0},
{0, 1, 1, 0, 0, 1, 0, 1},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 1},
{0, 1, 1, 0, 1, 0, 0, 0},
{0, 1, 1, 0, 1, 0, 0, 1},
{0, 1, 1, 0, 1, 0, 1, 0},
{0, 1, 1, 0, 1, 0, 1, 1},
{0, 1, 1, 0, 1, 1, 0, 0},
{0, 1, 1, 0, 1, 1, 0, 1},
{0, 1, 1, 0, 1, 1, 1, 0},
{0, 1, 1, 0, 1, 1, 1, 1},
{0, 1, 1, 1, 0, 0, 0, 0},
{0, 1, 1, 1, 0, 0, 0, 1},
{0, 1, 1, 1, 0, 0, 1, 0},
{0, 1, 1, 1, 0, 0, 1, 1},
{0, 1, 1, 1, 0, 1, 0, 0},
{0, 1, 1, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 0, 1, 1, 0},
{0, 1, 1, 1, 0, 1, 1, 1},
{0, 1, 1, 1, 1, 0, 0, 0},
{0, 1, 1, 1, 1, 0, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{0, 1, 1, 1, 1, 0, 1, 1},
{0, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0, 1},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 1, 0},
{1, 0, 0, 0, 0, 0, 1, 1},
{1, 0, 0, 0, 0, 1, 0, 0},
{1, 0, 0, 0, 0, 1, 0, 1},
{1, 0, 0, 0, 0, 1, 1, 0},
{1, 0, 0, 0, 0, 1, 1, 1},
{1, 0, 0, 0, 1, 0, 0, 0},
{1, 0, 0, 0, 1, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 1, 0},
{1, 0, 0, 0, 1, 0, 1, 1},
{1, 0, 0, 0, 1, 1, 0, 0},
{1, 0, 0, 0, 1, 1, 0, 1},
{1, 0, 0, 0, 1, 1, 1, 0},
{1, 0, 0, 0, 1, 1, 1, 1},
{1, 0, 0, 1, 0, 0, 0, 0},
{1, 0, 0, 1, 0, 0, 0, 1},
{1, 0, 0, 1, 0, 0, 1, 0},
{1, 0, 0, 1, 0, 0, 1, 1},
{1, 0, 0, 1, 0, 1, 0, 0},
{1, 0, 0, 1, 0, 1, 0, 1},
{1, 0, 0, 1, 0, 1, 1, 0},
{1, 0, 0, 1, 0, 1, 1, 1},
{1, 0, 0, 1, 1, 0, 0, 0},
{1, 0, 0, 1, 1, 0, 0, 1},
{1, 0, 0, 1, 1, 0, 1, 0},
{1, 0, 0, 1, 1, 0, 1, 1},
{1, 0, 0, 1, 1, 1, 0, 0},
{1, 0, 0, 1, 1, 1, 0, 1},
{1, 0, 0, 1, 1, 1, 1, 0},
{1, 0, 0, 1, 1, 1, 1, 1},
{1, 0, 1, 0, 0, 0, 0, 0},
{1, 0, 1, 0, 0, 0, 0, 1},
{1, 0, 1, 0, 0, 0, 1, 0},
{1, 0, 1, 0, 0, 0, 1, 1},
{1, 0, 1, 0, 0, 1, 0, 0},
{1, 0, 1, 0, 0, 1, 0, 1},
{1, 0, 1, 0, 0, 1, 1, 0},
{1, 0, 1, 0, 0, 1, 1, 1},
{1, 0, 1, 0, 1, 0, 0, 0},
{1, 0, 1, 0, 1, 0, 0, 1},
{1, 0, 1, 0, 1, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1, 1},
{1, 0, 1, 0, 1, 1, 0, 0},
{1, 0, 1, 0, 1, 1, 0, 1},
{1, 0, 1, 0, 1, 1, 1, 0},
{1, 0, 1, 0, 1, 1, 1, 1},
{1, 0, 1, 1, 0, 0, 0, 0},
{1, 0, 1, 1, 0, 0, 0, 1},
{1, 0, 1, 1, 0, 0, 1, 0},
{1, 0, 1, 1, 0, 0, 1, 1},
{1, 0, 1, 1, 0, 1, 0, 0},
{1, 0, 1, 1, 0, 1, 0, 1},
{1, 0, 1, 1, 0, 1, 1, 0},
{1, 0, 1, 1, 0, 1, 1, 1},
{1, 0, 1, 1, 1, 0, 0, 0},
{1, 0, 1, 1, 1, 0, 0, 1},
{1, 0, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 0, 1, 1},
{1, 0, 1, 1, 1, 1, 0, 0},
{1, 0, 1, 1, 1, 1, 0, 1},
{1, 0, 1, 1, 1, 1, 1, 0},
{1, 0, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 1},
{1, 1, 0, 0, 0, 0, 1, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 1, 0, 0},
{1, 1, 0, 0, 0, 1, 0, 1},
{1, 1, 0, 0, 0, 1, 1, 0},
{1, 1, 0, 0, 0, 1, 1, 1},
{1, 1, 0, 0, 1, 0, 0, 0},
{1, 1, 0, 0, 1, 0, 0, 1},
{1, 1, 0, 0, 1, 0, 1, 0},
{1, 1, 0, 0, 1, 0, 1, 1},
{1, 1, 0, 0, 1, 1, 0, 0},
{1, 1, 0, 0, 1, 1, 0, 1},
{1, 1, 0, 0, 1, 1, 1, 0},
{1, 1, 0, 0, 1, 1, 1, 1},
{1, 1, 0, 1, 0, 0, 0, 0},
{1, 1, 0, 1, 0, 0, 0, 1},
{1, 1, 0, 1, 0, 0, 1, 0},
{1, 1, 0, 1, 0, 0, 1, 1},
{1, 1, 0, 1, 0, 1, 0, 0},
{1, 1, 0, 1, 0, 1, 0, 1},
{1, 1, 0, 1, 0, 1, 1, 0},
{1, 1, 0, 1, 0, 1, 1, 1},
{1, 1, 0, 1, 1, 0, 0, 0},
{1, 1, 0, 1, 1, 0, 0, 1},
{1, 1, 0, 1, 1, 0, 1, 0},
{1, 1, 0, 1, 1, 0, 1, 1},
{1, 1, 0, 1, 1, 1, 0, 0},
{1, 1, 0, 1, 1, 1, 0, 1},
{1, 1, 0, 1, 1, 1, 1, 0},
{1, 1, 0, 1, 1, 1, 1, 1},
{1, 1, 1, 0, 0, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 1},
{1, 1, 1, 0, 0, 0, 1, 0},
{1, 1, 1, 0, 0, 0, 1, 1},
{1, 1, 1, 0, 0, 1, 0, 0},
{1, 1, 1, 0, 0, 1, 0, 1},
{1, 1, 1, 0, 0, 1, 1, 0},
{1, 1, 1, 0, 0, 1, 1, 1},
{1, 1, 1, 0, 1, 0, 0, 0},
{1, 1, 1, 0, 1, 0, 0, 1},
{1, 1, 1, 0, 1, 0, 1, 0},
{1, 1, 1, 0, 1, 0, 1, 1},
{1, 1, 1, 0, 1, 1, 0, 0},
{1, 1, 1, 0, 1, 1, 0, 1},
{1, 1, 1, 0, 1, 1, 1, 0},
{1, 1, 1, 0, 1, 1, 1, 1},
{1, 1, 1, 1, 0, 0, 0, 0},
{1, 1, 1, 1, 0, 0, 0, 1},
{1, 1, 1, 1, 0, 0, 1, 0},
{1, 1, 1, 1, 0, 0, 1, 1},
{1, 1, 1, 1, 0, 1, 0, 0},
{1, 1, 1, 1, 0, 1, 0, 1},
{1, 1, 1, 1, 0, 1, 1, 0},
{1, 1, 1, 1, 0, 1, 1, 1},
{1, 1, 1, 1, 1, 0, 0, 0},
{1, 1, 1, 1, 1, 0, 0, 1},
{1, 1, 1, 1, 1, 0, 1, 0},
{1, 1, 1, 1, 1, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1}};
    
    
double[] trainingTargets = {
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1

};



    
    
Multiof3 nn = new Multiof3();
    nn.train(trainingInputs, trainingTargets);
    
System.out.println("Prediction for [0, 0, 0, 0, 0, 0, 0, 0]: " + nn.predict(new double[]{0, 0, 0, 0, 0, 0, 0, 0}));
System.out.println("Prediction for [0, 0, 0, 0, 0, 0, 0, 1]: " + nn.predict(new double[]{0, 0, 0, 0, 0, 0, 0, 1}));
System.out.println("Prediction for [0, 0, 0, 0, 0, 0, 1, 0]: " + nn.predict(new double[]{0, 0, 0, 0, 0, 0, 1, 0}));
System.out.println("Prediction for [0, 0, 0, 0, 0, 0, 1, 1]: " + nn.predict(new double[]{0, 0, 0, 0, 0, 0, 1, 1}));
System.out.println("Prediction for [0, 0, 0, 0, 0, 1, 0, 0]: " + nn.predict(new double[]{0, 0, 0, 0, 0, 1, 0, 0}));
System.out.println("Prediction for [0, 0, 0, 0, 0, 1, 0, 1]: " + nn.predict(new double[]{0, 0, 0, 0, 0, 1, 0, 1}));
System.out.println("Prediction for [0, 0, 0, 0, 0, 1, 1, 0]: " + nn.predict(new double[]{0, 0, 0, 0, 0, 1, 1, 0}));
System.out.println("Prediction for [0, 0, 0, 0, 0, 1, 1, 1]: " + nn.predict(new double[]{0, 0, 0, 0, 0, 1, 1, 1}));
System.out.println("Prediction for [0, 0, 0, 0, 1, 0, 0, 0]: " + nn.predict(new double[]{0, 0, 0, 0, 1, 0, 0, 0}));
System.out.println("Prediction for [0, 0, 0, 0, 1, 0, 0, 1]: " + nn.predict(new double[]{0, 0, 0, 0, 1, 0, 0, 1}));
System.out.println("Prediction for [0, 0, 0, 0, 1, 0, 1, 0]: " + nn.predict(new double[]{0, 0, 0, 0, 1, 0, 1, 0}));
System.out.println("Prediction for [0, 0, 0, 0, 1, 0, 1, 1]: " + nn.predict(new double[]{0, 0, 0, 0, 1, 0, 1, 1}));
System.out.println("Prediction for [0, 0, 0, 0, 1, 1, 0, 0]: " + nn.predict(new double[]{0, 0, 0, 0, 1, 1, 0, 0}));
System.out.println("Prediction for [0, 0, 0, 0, 1, 1, 0, 1]: " + nn.predict(new double[]{0, 0, 0, 0, 1, 1, 0, 1}));
System.out.println("Prediction for [0, 0, 0, 0, 1, 1, 1, 0]: " + nn.predict(new double[]{0, 0, 0, 0, 1, 1, 1, 0}));
System.out.println("Prediction for [0, 0, 0, 0, 1, 1, 1, 1]: " + nn.predict(new double[]{0, 0, 0, 0, 1, 1, 1, 1}));
System.out.println("Prediction for [0, 0, 0, 1, 0, 0, 0, 0]: " + nn.predict(new double[]{0, 0, 0, 1, 0, 0, 0, 0}));
System.out.println("Prediction for [0, 0, 0, 1, 0, 0, 0, 1]: " + nn.predict(new double[]{0, 0, 0, 1, 0, 0, 0, 1}));
System.out.println("Prediction for [0, 0, 0, 1, 0, 0, 1, 0]: " + nn.predict(new double[]{0, 0, 0, 1, 0, 0, 1, 0}));
System.out.println("Prediction for [0, 0, 0, 1, 0, 0, 1, 1]: " + nn.predict(new double[]{0, 0, 0, 1, 0, 0, 1, 1}));
System.out.println("Prediction for [0, 0, 0, 1, 0, 1, 0, 0]: " + nn.predict(new double[]{0, 0, 0, 1, 0, 1, 0, 0}));
System.out.println("Prediction for [0, 0, 0, 1, 0, 1, 0, 1]: " + nn.predict(new double[]{0, 0, 0, 1, 0, 1, 0, 1}));
System.out.println("Prediction for [0, 0, 0, 1, 0, 1, 1, 0]: " + nn.predict(new double[]{0, 0, 0, 1, 0, 1, 1, 0}));
System.out.println("Prediction for [0, 0, 0, 1, 0, 1, 1, 1]: " + nn.predict(new double[]{0, 0, 0, 1, 0, 1, 1, 1}));   
System.out.println("Prediction for [0, 0, 0, 1, 1, 0, 0, 0]: " + nn.predict(new double[]{0, 0, 0, 1, 1, 0, 0, 0}));
System.out.println("Prediction for [0, 0, 0, 1, 1, 0, 0, 1]: " + nn.predict(new double[]{0, 0, 0, 1, 1, 0, 0, 1}));
System.out.println("Prediction for [0, 0, 0, 1, 1, 0, 1, 0]: " + nn.predict(new double[]{0, 0, 0, 1, 1, 0, 1, 0}));
System.out.println("Prediction for [0, 0, 0, 1, 1, 0, 1, 1]: " + nn.predict(new double[]{0, 0, 0, 1, 1, 0, 1, 1}));
System.out.println("Prediction for [0, 0, 0, 1, 1, 1, 0, 0]: " + nn.predict(new double[]{0, 0, 0, 1, 1, 1, 0, 0}));
System.out.println("Prediction for [0, 0, 0, 1, 1, 1, 0, 1]: " + nn.predict(new double[]{0, 0, 0, 1, 1, 1, 0, 1}));
System.out.println("Prediction for [0, 0, 0, 1, 1, 1, 1, 0]: " + nn.predict(new double[]{0, 0, 0, 1, 1, 1, 1, 0}));
System.out.println("Prediction for [0, 0, 0, 1, 1, 1, 1, 1]: " + nn.predict(new double[]{0, 0, 0, 1, 1, 1, 1, 1}));
System.out.println("Prediction for [0, 0, 1, 0, 0, 0, 0, 0]: " + nn.predict(new double[]{0, 0, 1, 0, 0, 0, 0, 0}));
System.out.println("Prediction for [0, 0, 1, 0, 0, 0, 0, 1]: " + nn.predict(new double[]{0, 0, 1, 0, 0, 0, 0, 1}));
System.out.println("Prediction for [0, 0, 1, 0, 0, 0, 1, 0]: " + nn.predict(new double[]{0, 0, 1, 0, 0, 0, 1, 0}));
System.out.println("Prediction for [0, 0, 1, 0, 0, 0, 1, 1]: " + nn.predict(new double[]{0, 0, 1, 0, 0, 0, 1, 1}));
System.out.println("Prediction for [0, 0, 1, 0, 0, 1, 0, 0]: " + nn.predict(new double[]{0, 0, 1, 0, 0, 1, 0, 0}));
System.out.println("Prediction for [0, 0, 1, 0, 0, 1, 0, 1]: " + nn.predict(new double[]{0, 0, 1, 0, 0, 1, 0, 1}));
System.out.println("Prediction for [0, 0, 1, 0, 0, 1, 1, 0]: " + nn.predict(new double[]{0, 0, 1, 0, 0, 1, 1, 0}));
System.out.println("Prediction for [0, 0, 1, 0, 0, 1, 1, 1]: " + nn.predict(new double[]{0, 0, 1, 0, 0, 1, 1, 1}));
System.out.println("Prediction for [0, 0, 1, 0, 1, 0, 0, 0]: " + nn.predict(new double[]{0, 0, 1, 0, 1, 0, 0, 0}));
System.out.println("Prediction for [0, 0, 1, 0, 1, 0, 0, 1]: " + nn.predict(new double[]{0, 0, 1, 0, 1, 0, 0, 1}));
System.out.println("Prediction for [0, 0, 1, 0, 1, 0, 1, 0]: " + nn.predict(new double[]{0, 0, 1, 0, 1, 0, 1, 0}));
System.out.println("Prediction for [0, 0, 1, 0, 1, 0, 1, 1]: " + nn.predict(new double[]{0, 0, 1, 0, 1, 0, 1, 1}));
System.out.println("Prediction for [0, 0, 1, 0, 1, 1, 0, 0]: " + nn.predict(new double[]{0, 0, 1, 0, 1, 1, 0, 0}));
System.out.println("Prediction for [0, 0, 1, 0, 1, 1, 0, 1]: " + nn.predict(new double[]{0, 0, 1, 0, 1, 1, 0, 1}));
System.out.println("Prediction for [0, 0, 1, 0, 1, 1, 1, 0]: " + nn.predict(new double[]{0, 0, 1, 0, 1, 1, 1, 0}));
System.out.println("Prediction for [0, 0, 1, 0, 1, 1, 1, 1]: " + nn.predict(new double[]{0, 0, 1, 0, 1, 1, 1, 1}));
System.out.println("Prediction for [0, 0, 1, 1, 0, 0, 0, 0]: " + nn.predict(new double[]{0, 0, 1, 1, 0, 0, 0, 0}));
System.out.println("Prediction for [0, 0, 1, 1, 0, 0, 0, 1]: " + nn.predict(new double[]{0, 0, 1, 1, 0, 0, 0, 1}));
System.out.println("Prediction for [0, 0, 1, 1, 0, 0, 1, 0]: " + nn.predict(new double[]{0, 0, 1, 1, 0, 0, 1, 0}));
System.out.println("Prediction for [0, 0, 1, 1, 0, 0, 1, 1]: " + nn.predict(new double[]{0, 0, 1, 1, 0, 0, 1, 1}));
System.out.println("Prediction for [0, 0, 1, 1, 0, 1, 0, 0]: " + nn.predict(new double[]{0, 0, 1, 1, 0, 1, 0, 0}));
System.out.println("Prediction for [0, 0, 1, 1, 0, 1, 0, 1]: " + nn.predict(new double[]{0, 0, 1, 1, 0, 1, 0, 1}));
System.out.println("Prediction for [0, 0, 1, 1, 0, 1, 1, 0]: " + nn.predict(new double[]{0, 0, 1, 1, 0, 1, 1, 0}));
System.out.println("Prediction for [0, 0, 1, 1, 0, 1, 1, 1]: " + nn.predict(new double[]{0, 0, 1, 1, 0, 1, 1, 1}));
System.out.println("Prediction for [0, 0, 1, 1, 1, 0, 0, 0]: " + nn.predict(new double[]{0, 0, 1, 1, 1, 0, 0, 0}));
System.out.println("Prediction for [0, 0, 1, 1, 1, 0, 0, 1]: " + nn.predict(new double[]{0, 0, 1, 1, 1, 0, 0, 1}));
System.out.println("Prediction for [0, 0, 1, 1, 1, 0, 1, 0]: " + nn.predict(new double[]{0, 0, 1, 1, 1, 0, 1, 0}));
System.out.println("Prediction for [0, 0, 1, 1, 1, 0, 1, 1]: " + nn.predict(new double[]{0, 0, 1, 1, 1, 0, 1, 1}));
System.out.println("Prediction for [0, 0, 1, 1, 1, 1, 0, 0]: " + nn.predict(new double[]{0, 0, 1, 1, 1, 1, 0, 0}));
System.out.println("Prediction for [0, 0, 1, 1, 1, 1, 0, 1]: " + nn.predict(new double[]{0, 0, 1, 1, 1, 1, 0, 1}));
System.out.println("Prediction for [0, 0, 1, 1, 1, 1, 1, 0]: " + nn.predict(new double[]{0, 0, 1, 1, 1, 1, 1, 0}));
System.out.println("Prediction for [0, 0, 1, 1, 1, 1, 1, 1]: " + nn.predict(new double[]{0, 0, 1, 1, 1, 1, 1, 1}));
System.out.println("Prediction for [0, 1, 0, 0, 0, 0, 0, 0]: " + nn.predict(new double[]{0, 1, 0, 0, 0, 0, 0, 0}));
System.out.println("Prediction for [0, 1, 0, 0, 0, 0, 0, 1]: " + nn.predict(new double[]{0, 1, 0, 0, 0, 0, 0, 1}));
System.out.println("Prediction for [0, 1, 0, 0, 0, 0, 1, 0]: " + nn.predict(new double[]{0, 1, 0, 0, 0, 0, 1, 0}));
System.out.println("Prediction for [0, 1, 0, 0, 0, 0, 1, 1]: " + nn.predict(new double[]{0, 1, 0, 0, 0, 0, 1, 1}));
System.out.println("Prediction for [0, 1, 0, 0, 0, 1, 0, 0]: " + nn.predict(new double[]{0, 1, 0, 0, 0, 1, 0, 0}));
System.out.println("Prediction for [0, 1, 0, 0, 0, 1, 0, 1]: " + nn.predict(new double[]{0, 1, 0, 0, 0, 1, 0, 1}));
System.out.println("Prediction for [0, 1, 0, 0, 0, 1, 1, 0]: " + nn.predict(new double[]{0, 1, 0, 0, 0, 1, 1, 0}));
System.out.println("Prediction for [0, 1, 0, 0, 0, 1, 1, 1]: " + nn.predict(new double[]{0, 1, 0, 0, 0, 1, 1, 1}));
System.out.println("Prediction for [0, 1, 0, 0, 1, 0, 0, 0]: " + nn.predict(new double[]{0, 1, 0, 0, 1, 0, 0, 0}));
System.out.println("Prediction for [0, 1, 0, 0, 1, 0, 0, 1]: " + nn.predict(new double[]{0, 1, 0, 0, 1, 0, 0, 1}));
System.out.println("Prediction for [0, 1, 0, 0, 1, 0, 1, 0]: " + nn.predict(new double[]{0, 1, 0, 0, 1, 0, 1, 0}));
System.out.println("Prediction for [0, 1, 0, 0, 1, 0, 1, 1]: " + nn.predict(new double[]{0, 1, 0, 0, 1, 0, 1, 1}));
System.out.println("Prediction for [0, 1, 0, 0, 1, 1, 0, 0]: " + nn.predict(new double[]{0, 1, 0, 0, 1, 1, 0, 0}));
System.out.println("Prediction for [0, 1, 0, 0, 1, 1, 0, 1]: " + nn.predict(new double[]{0, 1, 0, 0, 1, 1, 0, 1}));
System.out.println("Prediction for [0, 1, 0, 0, 1, 1, 1, 0]: " + nn.predict(new double[]{0, 1, 0, 0, 1, 1, 1, 0}));
System.out.println("Prediction for [0, 1, 0, 0, 1, 1, 1, 1]: " + nn.predict(new double[]{0, 1, 0, 0, 1, 1, 1, 1}));
System.out.println("Prediction for [0, 1, 0, 1, 0, 0, 0, 0]: " + nn.predict(new double[]{0, 1, 0, 1, 0, 0, 0, 0}));
System.out.println("Prediction for [0, 1, 0, 1, 0, 0, 0, 1]: " + nn.predict(new double[]{0, 1, 0, 1, 0, 0, 0, 1}));
System.out.println("Prediction for [0, 1, 0, 1, 0, 0, 1, 0]: " + nn.predict(new double[]{0, 1, 0, 1, 0, 0, 1, 0}));
System.out.println("Prediction for [0, 1, 0, 1, 0, 0, 1, 1]: " + nn.predict(new double[]{0, 1, 0, 1, 0, 0, 1, 1}));
System.out.println("Prediction for [0, 1, 0, 1, 0, 1, 0, 0]: " + nn.predict(new double[]{0, 1, 0, 1, 0, 1, 0, 0}));
System.out.println("Prediction for [0, 1, 0, 1, 0, 1, 0, 1]: " + nn.predict(new double[]{0, 1, 0, 1, 0, 1, 0, 1}));
System.out.println("Prediction for [0, 1, 0, 1, 0, 1, 1, 0]: " + nn.predict(new double[]{0, 1, 0, 1, 0, 1, 1, 0}));
System.out.println("Prediction for [0, 1, 0, 1, 0, 1, 1, 1]: " + nn.predict(new double[]{0, 1, 0, 1, 0, 1, 1, 1}));
System.out.println("Prediction for [0, 1, 0, 1, 1, 0, 0, 0]: " + nn.predict(new double[]{0, 1, 0, 1, 1, 0, 0, 0}));
System.out.println("Prediction for [0, 1, 0, 1, 1, 0, 0, 1]: " + nn.predict(new double[]{0, 1, 0, 1, 1, 0, 0, 1}));
System.out.println("Prediction for [0, 1, 0, 1, 1, 0, 1, 0]: " + nn.predict(new double[]{0, 1, 0, 1, 1, 0, 1, 0}));
System.out.println("Prediction for [0, 1, 0, 1, 1, 0, 1, 1]: " + nn.predict(new double[]{0, 1, 0, 1, 1, 0, 1, 1}));
System.out.println("Prediction for [0, 1, 0, 1, 1, 1, 0, 0]: " + nn.predict(new double[]{0, 1, 0, 1, 1, 1, 0, 0}));
System.out.println("Prediction for [0, 1, 0, 1, 1, 1, 0, 1]: " + nn.predict(new double[]{0, 1, 0, 1, 1, 1, 0, 1}));
System.out.println("Prediction for [0, 1, 0, 1, 1, 1, 1, 0]: " + nn.predict(new double[]{0, 1, 0, 1, 1, 1, 1, 0}));
System.out.println("Prediction for [0, 1, 0, 1, 1, 1, 1, 1]: " + nn.predict(new double[]{0, 1, 0, 1, 1, 1, 1, 1}));
System.out.println("Prediction for [0, 1, 1, 0, 0, 0, 0, 0]: " + nn.predict(new double[]{0, 1, 1, 0, 0, 0, 0, 0}));
System.out.println("Prediction for [0, 1, 1, 0, 0, 0, 0, 1]: " + nn.predict(new double[]{0, 1, 1, 0, 0, 0, 0, 1}));
System.out.println("Prediction for [0, 1, 1, 0, 0, 0, 1, 0]: " + nn.predict(new double[]{0, 1, 1, 0, 0, 0, 1, 0}));
System.out.println("Prediction for [0, 1, 1, 0, 0, 0, 1, 1]: " + nn.predict(new double[]{0, 1, 1, 0, 0, 0, 1, 1}));
System.out.println("Prediction for [0, 1, 1, 0, 0, 1, 0, 0]: " + nn.predict(new double[]{0, 1, 1, 0, 0, 1, 0, 0}));
System.out.println("Prediction for [0, 1, 1, 0, 0, 1, 0, 1]: " + nn.predict(new double[]{0, 1, 1, 0, 0, 1, 0, 1}));
System.out.println("Prediction for [0, 1, 1, 0, 0, 1, 1, 0]: " + nn.predict(new double[]{0, 1, 1, 0, 0, 1, 1, 0}));
System.out.println("Prediction for [0, 1, 1, 0, 0, 1, 1, 1]: " + nn.predict(new double[]{0, 1, 1, 0, 0, 1, 1, 1}));
System.out.println("Prediction for [0, 1, 1, 0, 1, 0, 0, 0]: " + nn.predict(new double[]{0, 1, 1, 0, 1, 0, 0, 0}));
System.out.println("Prediction for [0, 1, 1, 0, 1, 0, 0, 1]: " + nn.predict(new double[]{0, 1, 1, 0, 1, 0, 0, 1}));
System.out.println("Prediction for [0, 1, 1, 0, 1, 0, 1, 0]: " + nn.predict(new double[]{0, 1, 1, 0, 1, 0, 1, 0}));
System.out.println("Prediction for [0, 1, 1, 0, 1, 0, 1, 1]: " + nn.predict(new double[]{0, 1, 1, 0, 1, 0, 1, 1}));
System.out.println("Prediction for [0, 1, 1, 0, 1, 1, 0, 0]: " + nn.predict(new double[]{0, 1, 1, 0, 1, 1, 0, 0}));
System.out.println("Prediction for [0, 1, 1, 0, 1, 1, 0, 1]: " + nn.predict(new double[]{0, 1, 1, 0, 1, 1, 0, 1}));
System.out.println("Prediction for [0, 1, 1, 0, 1, 1, 1, 0]: " + nn.predict(new double[]{0, 1, 1, 0, 1, 1, 1, 0}));
System.out.println("Prediction for [0, 1, 1, 0, 1, 1, 1, 1]: " + nn.predict(new double[]{0, 1, 1, 0, 1, 1, 1, 1}));
System.out.println("Prediction for [0, 1, 1, 1, 0, 0, 0, 0]: " + nn.predict(new double[]{0, 1, 1, 1, 0, 0, 0, 0}));
System.out.println("Prediction for [0, 1, 1, 1, 0, 0, 0, 1]: " + nn.predict(new double[]{0, 1, 1, 1, 0, 0, 0, 1}));
System.out.println("Prediction for [0, 1, 1, 1, 0, 0, 1, 0]: " + nn.predict(new double[]{0, 1, 1, 1, 0, 0, 1, 0}));
System.out.println("Prediction for [0, 1, 1, 1, 0, 0, 1, 1]: " + nn.predict(new double[]{0, 1, 1, 1, 0, 0, 1, 1}));
System.out.println("Prediction for [0, 1, 1, 1, 0, 1, 0, 0]: " + nn.predict(new double[]{0, 1, 1, 1, 0, 1, 0, 0}));
System.out.println("Prediction for [0, 1, 1, 1, 0, 1, 0, 1]: " + nn.predict(new double[]{0, 1, 1, 1, 0, 1, 0, 1}));
System.out.println("Prediction for [0, 1, 1, 1, 0, 1, 1, 0]: " + nn.predict(new double[]{0, 1, 1, 1, 0, 1, 1, 0}));
System.out.println("Prediction for [0, 1, 1, 1, 0, 1, 1, 1]: " + nn.predict(new double[]{0, 1, 1, 1, 0, 1, 1, 1}));
System.out.println("Prediction for [0, 1, 1, 1, 1, 0, 0, 0]: " + nn.predict(new double[]{0, 1, 1, 1, 1, 0, 0, 0}));
System.out.println("Prediction for [0, 1, 1, 1, 1, 0, 0, 1]: " + nn.predict(new double[]{0, 1, 1, 1, 1, 0, 0, 1}));
System.out.println("Prediction for [0, 1, 1, 1, 1, 0, 1, 0]: " + nn.predict(new double[]{0, 1, 1, 1, 1, 0, 1, 0}));
System.out.println("Prediction for [0, 1, 1, 1, 1, 0, 1, 1]: " + nn.predict(new double[]{0, 1, 1, 1, 1, 0, 1, 1}));
System.out.println("Prediction for [0, 1, 1, 1, 1, 1, 0, 0]: " + nn.predict(new double[]{0, 1, 1, 1, 1, 1, 0, 0}));
System.out.println("Prediction for [0, 1, 1, 1, 1, 1, 0, 1]: " + nn.predict(new double[]{0, 1, 1, 1, 1, 1, 0, 1}));
System.out.println("Prediction for [0, 1, 1, 1, 1, 1, 1, 0]: " + nn.predict(new double[]{0, 1, 1, 1, 1, 1, 1, 0}));
System.out.println("Prediction for [0, 1, 1, 1, 1, 1, 1, 1]: " + nn.predict(new double[]{0, 1, 1, 1, 1, 1, 1, 1}));
System.out.println("Prediction for [1, 0, 0, 0, 0, 0, 0, 0]: " + nn.predict(new double[]{1, 0, 0, 0, 0, 0, 0, 0}));
System.out.println("Prediction for [1, 0, 0, 0, 0, 0, 0, 1]: " + nn.predict(new double[]{1, 0, 0, 0, 0, 0, 0, 1}));
System.out.println("Prediction for [1, 0, 0, 0, 0, 0, 1, 0]: " + nn.predict(new double[]{1, 0, 0, 0, 0, 0, 1, 0}));
System.out.println("Prediction for [1, 0, 0, 0, 0, 0, 1, 1]: " + nn.predict(new double[]{1, 0, 0, 0, 0, 0, 1, 1}));
System.out.println("Prediction for [1, 0, 0, 0, 0, 1, 0, 0]: " + nn.predict(new double[]{1, 0, 0, 0, 0, 1, 0, 0}));
System.out.println("Prediction for [1, 0, 0, 0, 0, 1, 0, 1]: " + nn.predict(new double[]{1, 0, 0, 0, 0, 1, 0, 1}));
System.out.println("Prediction for [1, 0, 0, 0, 0, 1, 1, 0]: " + nn.predict(new double[]{1, 0, 0, 0, 0, 1, 1, 0}));
System.out.println("Prediction for [1, 0, 0, 0, 0, 1, 1, 1]: " + nn.predict(new double[]{1, 0, 0, 0, 0, 1, 1, 1}));
System.out.println("Prediction for [1, 0, 0, 0, 1, 0, 0, 0]: " + nn.predict(new double[]{1, 0, 0, 0, 1, 0, 0, 0}));
System.out.println("Prediction for [1, 0, 0, 0, 1, 0, 0, 1]: " + nn.predict(new double[]{1, 0, 0, 0, 1, 0, 0, 1}));
System.out.println("Prediction for [1, 0, 0, 0, 1, 0, 1, 0]: " + nn.predict(new double[]{1, 0, 0, 0, 1, 0, 1, 0}));
System.out.println("Prediction for [1, 0, 0, 0, 1, 0, 1, 1]: " + nn.predict(new double[]{1, 0, 0, 0, 1, 0, 1, 1}));
System.out.println("Prediction for [1, 0, 0, 0, 1, 1, 0, 0]: " + nn.predict(new double[]{1, 0, 0, 0, 1, 1, 0, 0}));
System.out.println("Prediction for [1, 0, 0, 0, 1, 1, 0, 1]: " + nn.predict(new double[]{1, 0, 0, 0, 1, 1, 0, 1}));
System.out.println("Prediction for [1, 0, 0, 0, 1, 1, 1, 0]: " + nn.predict(new double[]{1, 0, 0, 0, 1, 1, 1, 0}));
System.out.println("Prediction for [1, 0, 0, 0, 1, 1, 1, 1]: " + nn.predict(new double[]{1, 0, 0, 0, 1, 1, 1, 1}));
System.out.println("Prediction for [1, 0, 0, 1, 0, 0, 0, 0]: " + nn.predict(new double[]{1, 0, 0, 1, 0, 0, 0, 0}));
System.out.println("Prediction for [1, 0, 0, 1, 0, 0, 0, 1]: " + nn.predict(new double[]{1, 0, 0, 1, 0, 0, 0, 1}));
System.out.println("Prediction for [1, 0, 0, 1, 0, 0, 1, 0]: " + nn.predict(new double[]{1, 0, 0, 1, 0, 0, 1, 0}));
System.out.println("Prediction for [1, 0, 0, 1, 0, 0, 1, 1]: " + nn.predict(new double[]{1, 0, 0, 1, 0, 0, 1, 1}));
System.out.println("Prediction for [1, 0, 0, 1, 0, 1, 0, 0]: " + nn.predict(new double[]{1, 0, 0, 1, 0, 1, 0, 0}));
System.out.println("Prediction for [1, 0, 0, 1, 0, 1, 0, 1]: " + nn.predict(new double[]{1, 0, 0, 1, 0, 1, 0, 1}));
System.out.println("Prediction for [1, 0, 0, 1, 0, 1, 1, 0]: " + nn.predict(new double[]{1, 0, 0, 1, 0, 1, 1, 0}));
System.out.println("Prediction for [1, 0, 0, 1, 0, 1, 1, 1]: " + nn.predict(new double[]{1, 0, 0, 1, 0, 1, 1, 1}));
System.out.println("Prediction for [1, 0, 0, 1, 1, 0, 0, 0]: " + nn.predict(new double[]{1, 0, 0, 1, 1, 0, 0, 0}));
System.out.println("Prediction for [1, 0, 0, 1, 1, 0, 0, 1]: " + nn.predict(new double[]{1, 0, 0, 1, 1, 0, 0, 1}));
System.out.println("Prediction for [1, 0, 0, 1, 1, 0, 1, 0]: " + nn.predict(new double[]{1, 0, 0, 1, 1, 0, 1, 0}));
System.out.println("Prediction for [1, 0, 0, 1, 1, 0, 1, 1]: " + nn.predict(new double[]{1, 0, 0, 1, 1, 0, 1, 1}));
System.out.println("Prediction for [1, 0, 0, 1, 1, 1, 0, 0]: " + nn.predict(new double[]{1, 0, 0, 1, 1, 1, 0, 0}));
System.out.println("Prediction for [1, 0, 0, 1, 1, 1, 0, 1]: " + nn.predict(new double[]{1, 0, 0, 1, 1, 1, 0, 1}));
System.out.println("Prediction for [1, 0, 0, 1, 1, 1, 1, 0]: " + nn.predict(new double[]{1, 0, 0, 1, 1, 1, 1, 0}));
System.out.println("Prediction for [1, 0, 0, 1, 1, 1, 1, 1]: " + nn.predict(new double[]{1, 0, 0, 1, 1, 1, 1, 1}));
System.out.println("Prediction for [1, 0, 1, 0, 0, 0, 0, 0]: " + nn.predict(new double[]{1, 0, 1, 0, 0, 0, 0, 0}));
System.out.println("Prediction for [1, 0, 1, 0, 0, 0, 0, 1]: " + nn.predict(new double[]{1, 0, 1, 0, 0, 0, 0, 1}));
System.out.println("Prediction for [1, 0, 1, 0, 0, 0, 1, 0]: " + nn.predict(new double[]{1, 0, 1, 0, 0, 0, 1, 0}));
System.out.println("Prediction for [1, 0, 1, 0, 0, 0, 1, 1]: " + nn.predict(new double[]{1, 0, 1, 0, 0, 0, 1, 1}));
System.out.println("Prediction for [1, 0, 1, 0, 0, 1, 0, 0]: " + nn.predict(new double[]{1, 0, 1, 0, 0, 1, 0, 0}));
System.out.println("Prediction for [1, 0, 1, 0, 0, 1, 0, 1]: " + nn.predict(new double[]{1, 0, 1, 0, 0, 1, 0, 1}));
System.out.println("Prediction for [1, 0, 1, 0, 0, 1, 1, 0]: " + nn.predict(new double[]{1, 0, 1, 0, 0, 1, 1, 0}));
System.out.println("Prediction for [1, 0, 1, 0, 0, 1, 1, 1]: " + nn.predict(new double[]{1, 0, 1, 0, 0, 1, 1, 1}));
System.out.println("Prediction for [1, 0, 1, 0, 1, 0, 0, 0]: " + nn.predict(new double[]{1, 0, 1, 0, 1, 0, 0, 0}));
System.out.println("Prediction for [1, 0, 1, 0, 1, 0, 0, 1]: " + nn.predict(new double[]{1, 0, 1, 0, 1, 0, 0, 1}));
System.out.println("Prediction for [1, 0, 1, 0, 1, 0, 1, 0]: " + nn.predict(new double[]{1, 0, 1, 0, 1, 0, 1, 0}));
System.out.println("Prediction for [1, 0, 1, 0, 1, 0, 1, 1]: " + nn.predict(new double[]{1, 0, 1, 0, 1, 0, 1, 1}));
System.out.println("Prediction for [1, 0, 1, 0, 1, 1, 0, 0]: " + nn.predict(new double[]{1, 0, 1, 0, 1, 1, 0, 0}));
System.out.println("Prediction for [1, 0, 1, 0, 1, 1, 0, 1]: " + nn.predict(new double[]{1, 0, 1, 0, 1, 1, 0, 1}));
System.out.println("Prediction for [1, 0, 1, 0, 1, 1, 1, 0]: " + nn.predict(new double[]{1, 0, 1, 0, 1, 1, 1, 0}));
System.out.println("Prediction for [1, 0, 1, 0, 1, 1, 1, 1]: " + nn.predict(new double[]{1, 0, 1, 0, 1, 1, 1, 1}));
System.out.println("Prediction for [1, 0, 1, 1, 0, 0, 0, 0]: " + nn.predict(new double[]{1, 0, 1, 1, 0, 0, 0, 0}));
System.out.println("Prediction for [1, 0, 1, 1, 0, 0, 0, 1]: " + nn.predict(new double[]{1, 0, 1, 1, 0, 0, 0, 1}));
System.out.println("Prediction for [1, 0, 1, 1, 0, 0, 1, 0]: " + nn.predict(new double[]{1, 0, 1, 1, 0, 0, 1, 0}));
System.out.println("Prediction for [1, 0, 1, 1, 0, 0, 1, 1]: " + nn.predict(new double[]{1, 0, 1, 1, 0, 0, 1, 1}));
System.out.println("Prediction for [1, 0, 1, 1, 0, 1, 0, 0]: " + nn.predict(new double[]{1, 0, 1, 1, 0, 1, 0, 0}));
System.out.println("Prediction for [1, 0, 1, 1, 0, 1, 0, 1]: " + nn.predict(new double[]{1, 0, 1, 1, 0, 1, 0, 1}));
System.out.println("Prediction for [1, 0, 1, 1, 0, 1, 1, 0]: " + nn.predict(new double[]{1, 0, 1, 1, 0, 1, 1, 0}));
System.out.println("Prediction for [1, 0, 1, 1, 0, 1, 1, 1]: " + nn.predict(new double[]{1, 0, 1, 1, 0, 1, 1, 1}));
System.out.println("Prediction for [1, 0, 1, 1, 1, 0, 0, 0]: " + nn.predict(new double[]{1, 0, 1, 1, 1, 0, 0, 0}));
System.out.println("Prediction for [1, 0, 1, 1, 1, 0, 0, 1]: " + nn.predict(new double[]{1, 0, 1, 1, 1, 0, 0, 1}));
System.out.println("Prediction for [1, 0, 1, 1, 1, 0, 1, 0]: " + nn.predict(new double[]{1, 0, 1, 1, 1, 0, 1, 0}));
System.out.println("Prediction for [1, 0, 1, 1, 1, 0, 1, 1]: " + nn.predict(new double[]{1, 0, 1, 1, 1, 0, 1, 1}));
System.out.println("Prediction for [1, 0, 1, 1, 1, 1, 0, 0]: " + nn.predict(new double[]{1, 0, 1, 1, 1, 1, 0, 0}));
System.out.println("Prediction for [1, 0, 1, 1, 1, 1, 0, 1]: " + nn.predict(new double[]{1, 0, 1, 1, 1, 1, 0, 1}));
System.out.println("Prediction for [1, 0, 1, 1, 1, 1, 1, 0]: " + nn.predict(new double[]{1, 0, 1, 1, 1, 1, 1, 0}));
System.out.println("Prediction for [1, 0, 1, 1, 1, 1, 1, 1]: " + nn.predict(new double[]{1, 0, 1, 1, 1, 1, 1, 1}));
System.out.println("Prediction for [1, 1, 0, 0, 0, 0, 0, 0]: " + nn.predict(new double[]{1, 1, 0, 0, 0, 0, 0, 0}));
System.out.println("Prediction for [1, 1, 0, 0, 0, 0, 0, 1]: " + nn.predict(new double[]{1, 1, 0, 0, 0, 0, 0, 1}));
System.out.println("Prediction for [1, 1, 0, 0, 0, 0, 1, 0]: " + nn.predict(new double[]{1, 1, 0, 0, 0, 0, 1, 0}));
System.out.println("Prediction for [1, 1, 0, 0, 0, 0, 1, 1]: " + nn.predict(new double[]{1, 1, 0, 0, 0, 0, 1, 1}));
System.out.println("Prediction for [1, 1, 0, 0, 0, 1, 0, 0]: " + nn.predict(new double[]{1, 1, 0, 0, 0, 1, 0, 0}));
System.out.println("Prediction for [1, 1, 0, 0, 0, 1, 0, 1]: " + nn.predict(new double[]{1, 1, 0, 0, 0, 1, 0, 1}));
System.out.println("Prediction for [1, 1, 0, 0, 0, 1, 1, 0]: " + nn.predict(new double[]{1, 1, 0, 0, 0, 1, 1, 0}));
System.out.println("Prediction for [1, 1, 0, 0, 0, 1, 1, 1]: " + nn.predict(new double[]{1, 1, 0, 0, 0, 1, 1, 1}));
System.out.println("Prediction for [1, 1, 0, 0, 1, 0, 0, 0]: " + nn.predict(new double[]{1, 1, 0, 0, 1, 0, 0, 0}));
System.out.println("Prediction for [1, 1, 0, 0, 1, 0, 0, 1]: " + nn.predict(new double[]{1, 1, 0, 0, 1, 0, 0, 1}));
System.out.println("Prediction for [1, 1, 0, 0, 1, 0, 1, 0]: " + nn.predict(new double[]{1, 1, 0, 0, 1, 0, 1, 0}));
System.out.println("Prediction for [1, 1, 0, 0, 1, 0, 1, 1]: " + nn.predict(new double[]{1, 1, 0, 0, 1, 0, 1, 1}));
System.out.println("Prediction for [1, 1, 0, 0, 1, 1, 0, 0]: " + nn.predict(new double[]{1, 1, 0, 0, 1, 1, 0, 0}));
System.out.println("Prediction for [1, 1, 0, 0, 1, 1, 0, 1]: " + nn.predict(new double[]{1, 1, 0, 0, 1, 1, 0, 1}));
System.out.println("Prediction for [1, 1, 0, 0, 1, 1, 1, 0]: " + nn.predict(new double[]{1, 1, 0, 0, 1, 1, 1, 0}));
System.out.println("Prediction for [1, 1, 0, 0, 1, 1, 1, 1]: " + nn.predict(new double[]{1, 1, 0, 0, 1, 1, 1, 1}));
System.out.println("Prediction for [1, 1, 0, 1, 0, 0, 0, 0]: " + nn.predict(new double[]{1, 1, 0, 1, 0, 0, 0, 0}));
System.out.println("Prediction for [1, 1, 0, 1, 0, 0, 0, 1]: " + nn.predict(new double[]{1, 1, 0, 1, 0, 0, 0, 1}));
System.out.println("Prediction for [1, 1, 0, 1, 0, 0, 1, 0]: " + nn.predict(new double[]{1, 1, 0, 1, 0, 0, 1, 0}));
System.out.println("Prediction for [1, 1, 0, 1, 0, 0, 1, 1]: " + nn.predict(new double[]{1, 1, 0, 1, 0, 0, 1, 1}));
System.out.println("Prediction for [1, 1, 0, 1, 0, 1, 0, 0]: " + nn.predict(new double[]{1, 1, 0, 1, 0, 1, 0, 0}));
System.out.println("Prediction for [1, 1, 0, 1, 0, 1, 0, 1]: " + nn.predict(new double[]{1, 1, 0, 1, 0, 1, 0, 1}));
System.out.println("Prediction for [1, 1, 0, 1, 0, 1, 1, 0]: " + nn.predict(new double[]{1, 1, 0, 1, 0, 1, 1, 0}));
System.out.println("Prediction for [1, 1, 0, 1, 0, 1, 1, 1]: " + nn.predict(new double[]{1, 1, 0, 1, 0, 1, 1, 1}));
System.out.println("Prediction for [1, 1, 0, 1, 1, 0, 0, 0]: " + nn.predict(new double[]{1, 1, 0, 1, 1, 0, 0, 0}));
System.out.println("Prediction for [1, 1, 0, 1, 1, 0, 0, 1]: " + nn.predict(new double[]{1, 1, 0, 1, 1, 0, 0, 1}));
System.out.println("Prediction for [1, 1, 0, 1, 1, 0, 1, 0]: " + nn.predict(new double[]{1, 1, 0, 1, 1, 0, 1, 0}));
System.out.println("Prediction for [1, 1, 0, 1, 1, 0, 1, 1]: " + nn.predict(new double[]{1, 1, 0, 1, 1, 0, 1, 1}));
System.out.println("Prediction for [1, 1, 0, 1, 1, 1, 0, 0]: " + nn.predict(new double[]{1, 1, 0, 1, 1, 1, 0, 0}));
System.out.println("Prediction for [1, 1, 0, 1, 1, 1, 0, 1]: " + nn.predict(new double[]{1, 1, 0, 1, 1, 1, 0, 1}));
System.out.println("Prediction for [1, 1, 0, 1, 1, 1, 1, 0]: " + nn.predict(new double[]{1, 1, 0, 1, 1, 1, 1, 0}));
System.out.println("Prediction for [1, 1, 0, 1, 1, 1, 1, 1]: " + nn.predict(new double[]{1, 1, 0, 1, 1, 1, 1, 1}));
System.out.println("Prediction for [1, 1, 1, 0, 0, 0, 0, 0]: " + nn.predict(new double[]{1, 1, 1, 0, 0, 0, 0, 0}));
System.out.println("Prediction for [1, 1, 1, 0, 0, 0, 0, 1]: " + nn.predict(new double[]{1, 1, 1, 0, 0, 0, 0, 1}));
System.out.println("Prediction for [1, 1, 1, 0, 0, 0, 1, 0]: " + nn.predict(new double[]{1, 1, 1, 0, 0, 0, 1, 0}));
System.out.println("Prediction for [1, 1, 1, 0, 0, 0, 1, 1]: " + nn.predict(new double[]{1, 1, 1, 0, 0, 0, 1, 1}));
System.out.println("Prediction for [1, 1, 1, 0, 0, 1, 0, 0]: " + nn.predict(new double[]{1, 1, 1, 0, 0, 1, 0, 0}));
System.out.println("Prediction for [1, 1, 1, 0, 0, 1, 0, 1]: " + nn.predict(new double[]{1, 1, 1, 0, 0, 1, 0, 1}));
System.out.println("Prediction for [1, 1, 1, 0, 0, 1, 1, 0]: " + nn.predict(new double[]{1, 1, 1, 0, 0, 1, 1, 0}));
System.out.println("Prediction for [1, 1, 1, 0, 0, 1, 1, 1]: " + nn.predict(new double[]{1, 1, 1, 0, 0, 1, 1, 1}));
System.out.println("Prediction for [1, 1, 1, 0, 1, 0, 0, 0]: " + nn.predict(new double[]{1, 1, 1, 0, 1, 0, 0, 0}));
System.out.println("Prediction for [1, 1, 1, 0, 1, 0, 0, 1]: " + nn.predict(new double[]{1, 1, 1, 0, 1, 0, 0, 1}));
System.out.println("Prediction for [1, 1, 1, 0, 1, 0, 1, 0]: " + nn.predict(new double[]{1, 1, 1, 0, 1, 0, 1, 0}));
System.out.println("Prediction for [1, 1, 1, 0, 1, 0, 1, 1]: " + nn.predict(new double[]{1, 1, 1, 0, 1, 0, 1, 1}));
System.out.println("Prediction for [1, 1, 1, 0, 1, 1, 0, 0]: " + nn.predict(new double[]{1, 1, 1, 0, 1, 1, 0, 0}));
System.out.println("Prediction for [1, 1, 1, 0, 1, 1, 0, 1]: " + nn.predict(new double[]{1, 1, 1, 0, 1, 1, 0, 1}));
System.out.println("Prediction for [1, 1, 1, 0, 1, 1, 1, 0]: " + nn.predict(new double[]{1, 1, 1, 0, 1, 1, 1, 0}));
System.out.println("Prediction for [1, 1, 1, 0, 1, 1, 1, 1]: " + nn.predict(new double[]{1, 1, 1, 0, 1, 1, 1, 1}));
System.out.println("Prediction for [1, 1, 1, 1, 0, 0, 0, 0]: " + nn.predict(new double[]{1, 1, 1, 1, 0, 0, 0, 0}));
System.out.println("Prediction for [1, 1, 1, 1, 0, 0, 0, 1]: " + nn.predict(new double[]{1, 1, 1, 1, 0, 0, 0, 1}));
System.out.println("Prediction for [1, 1, 1, 1, 0, 0, 1, 0]: " + nn.predict(new double[]{1, 1, 1, 1, 0, 0, 1, 0}));
System.out.println("Prediction for [1, 1, 1, 1, 0, 0, 1, 1]: " + nn.predict(new double[]{1, 1, 1, 1, 0, 0, 1, 1}));
System.out.println("Prediction for [1, 1, 1, 1, 0, 1, 0, 0]: " + nn.predict(new double[]{1, 1, 1, 1, 0, 1, 0, 0}));
System.out.println("Prediction for [1, 1, 1, 1, 0, 1, 0, 1]: " + nn.predict(new double[]{1, 1, 1, 1, 0, 1, 0, 1}));
System.out.println("Prediction for [1, 1, 1, 1, 0, 1, 1, 0]: " + nn.predict(new double[]{1, 1, 1, 1, 0, 1, 1, 0}));
System.out.println("Prediction for [1, 1, 1, 1, 0, 1, 1, 1]: " + nn.predict(new double[]{1, 1, 1, 1, 0, 1, 1, 1}));
System.out.println("Prediction for [1, 1, 1, 1, 1, 0, 0, 0]: " + nn.predict(new double[]{1, 1, 1, 1, 1, 0, 0, 0}));
System.out.println("Prediction for [1, 1, 1, 1, 1, 0, 0, 1]: " + nn.predict(new double[]{1, 1, 1, 1, 1, 0, 0, 1}));
System.out.println("Prediction for [1, 1, 1, 1, 1, 0, 1, 0]: " + nn.predict(new double[]{1, 1, 1, 1, 1, 0, 1, 0}));
System.out.println("Prediction for [1, 1, 1, 1, 1, 0, 1, 1]: " + nn.predict(new double[]{1, 1, 1, 1, 1, 0, 1, 1}));
System.out.println("Prediction for [1, 1, 1, 1, 1, 1, 0, 0]: " + nn.predict(new double[]{1, 1, 1, 1, 1, 1, 0, 0}));
System.out.println("Prediction for [1, 1, 1, 1, 1, 1, 0, 1]: " + nn.predict(new double[]{1, 1, 1, 1, 1, 1, 0, 1}));
System.out.println("Prediction for [1, 1, 1, 1, 1, 1, 1, 0]: " + nn.predict(new double[]{1, 1, 1, 1, 1, 1, 1, 0}));
System.out.println("Prediction for [1, 1, 1, 1, 1, 1, 1, 1]: " + nn.predict(new double[]{1, 1, 1, 1, 1, 1, 1, 1}));


}


}






}


}

                                           
run:
Epoch 10000. Mean error: 0.03320182397344079
Epoch 20000. Mean error: 0.015664910563958027
Epoch 30000. Mean error: 0.010995680121444898
Epoch 40000. Mean error: 0.007215736479517636
Epoch 50000. Mean error: 0.004671420467816973
Epoch 60000. Mean error: 0.0033333409994070725
Epoch 70000. Mean error: 0.002438821540547091
Epoch 80000. Mean error: 0.001797394851011058
Epoch 90000. Mean error: 0.0014285088523369675
Epoch 100000. Mean error: 0.0011159668898050722
Prediction for [0, 0, 0, 0, 0, 0, 0, 0]: 1.002249807094342
Prediction for [0, 0, 0, 0, 0, 0, 0, 1]: 0.0
Prediction for [0, 0, 0, 0, 0, 0, 1, 0]: 0.0
Prediction for [0, 0, 0, 0, 0, 0, 1, 1]: 1.005775312107044
Prediction for [0, 0, 0, 0, 0, 1, 0, 0]: 0.0
Prediction for [0, 0, 0, 0, 0, 1, 0, 1]: 0.0
Prediction for [0, 0, 0, 0, 0, 1, 1, 0]: 1.0034494127090006
Prediction for [0, 0, 0, 0, 0, 1, 1, 1]: 0.0
Prediction for [0, 0, 0, 0, 1, 0, 0, 0]: 0.0
Prediction for [0, 0, 0, 0, 1, 0, 0, 1]: 0.9975595819738396
Prediction for [0, 0, 0, 0, 1, 0, 1, 0]: 0.0
Prediction for [0, 0, 0, 0, 1, 0, 1, 1]: 0.0
Prediction for [0, 0, 0, 0, 1, 1, 0, 0]: 1.0002228674093439
Prediction for [0, 0, 0, 0, 1, 1, 0, 1]: 0.0
Prediction for [0, 0, 0, 0, 1, 1, 1, 0]: 0.0
Prediction for [0, 0, 0, 0, 1, 1, 1, 1]: 0.9902095019746442
Prediction for [0, 0, 0, 1, 0, 0, 0, 0]: 0.0
Prediction for [0, 0, 0, 1, 0, 0, 0, 1]: 0.0
Prediction for [0, 0, 0, 1, 0, 0, 1, 0]: 1.0042265172554652
Prediction for [0, 0, 0, 1, 0, 0, 1, 1]: 0.0
Prediction for [0, 0, 0, 1, 0, 1, 0, 0]: 0.0
Prediction for [0, 0, 0, 1, 0, 1, 0, 1]: 1.0003704405106806
Prediction for [0, 0, 0, 1, 0, 1, 1, 0]: 0.0
Prediction for [0, 0, 0, 1, 0, 1, 1, 1]: 0.0
Prediction for [0, 0, 0, 1, 1, 0, 0, 0]: 0.9751408395568495
Prediction for [0, 0, 0, 1, 1, 0, 0, 1]: 0.0
Prediction for [0, 0, 0, 1, 1, 0, 1, 0]: 0.01649011799176181
Prediction for [0, 0, 0, 1, 1, 0, 1, 1]: 1.0099744674039748
Prediction for [0, 0, 0, 1, 1, 1, 0, 0]: 0.0
Prediction for [0, 0, 0, 1, 1, 1, 0, 1]: 0.0
Prediction for [0, 0, 0, 1, 1, 1, 1, 0]: 0.9863943579630314
Prediction for [0, 0, 0, 1, 1, 1, 1, 1]: 0.0
Prediction for [0, 0, 1, 0, 0, 0, 0, 0]: 0.21004743488120203
Prediction for [0, 0, 1, 0, 0, 0, 0, 1]: 0.9871866923531987
Prediction for [0, 0, 1, 0, 0, 0, 1, 0]: 0.0
Prediction for [0, 0, 1, 0, 0, 0, 1, 1]: 0.0
Prediction for [0, 0, 1, 0, 0, 1, 0, 0]: 1.0055183578932958
Prediction for [0, 0, 1, 0, 0, 1, 0, 1]: 0.0
Prediction for [0, 0, 1, 0, 0, 1, 1, 0]: 0.007120716120785353
Prediction for [0, 0, 1, 0, 0, 1, 1, 1]: 1.00379851918703
Prediction for [0, 0, 1, 0, 1, 0, 0, 0]: 0.0
Prediction for [0, 0, 1, 0, 1, 0, 0, 1]: 0.0
Prediction for [0, 0, 1, 0, 1, 0, 1, 0]: 0.7938630246637777
Prediction for [0, 0, 1, 0, 1, 0, 1, 1]: 0.0
Prediction for [0, 0, 1, 0, 1, 1, 0, 0]: 0.0
Prediction for [0, 0, 1, 0, 1, 1, 0, 1]: 0.9993393098917904
Prediction for [0, 0, 1, 0, 1, 1, 1, 0]: 0.0
Prediction for [0, 0, 1, 0, 1, 1, 1, 1]: 0.0
Prediction for [0, 0, 1, 1, 0, 0, 0, 0]: 0.7572283242298994
Prediction for [0, 0, 1, 1, 0, 0, 0, 1]: 0.0
Prediction for [0, 0, 1, 1, 0, 0, 1, 0]: 0.0
Prediction for [0, 0, 1, 1, 0, 0, 1, 1]: 0.9812761572917124
Prediction for [0, 0, 1, 1, 0, 1, 0, 0]: 0.0
Prediction for [0, 0, 1, 1, 0, 1, 0, 1]: 0.0
Prediction for [0, 0, 1, 1, 0, 1, 1, 0]: 0.9440805364880465
Prediction for [0, 0, 1, 1, 0, 1, 1, 1]: 0.0
Prediction for [0, 0, 1, 1, 1, 0, 0, 0]: 0.20689955481321753
Prediction for [0, 0, 1, 1, 1, 0, 0, 1]: 0.9468425725710206
Prediction for [0, 0, 1, 1, 1, 0, 1, 0]: 0.14114103381935905
Prediction for [0, 0, 1, 1, 1, 0, 1, 1]: 0.0643811102070515
Prediction for [0, 0, 1, 1, 1, 1, 0, 0]: 0.9906340356689181
Prediction for [0, 0, 1, 1, 1, 1, 0, 1]: 0.0
Prediction for [0, 0, 1, 1, 1, 1, 1, 0]: 0.03353389575501842
Prediction for [0, 0, 1, 1, 1, 1, 1, 1]: 1.0193903184820603
Prediction for [0, 1, 0, 0, 0, 0, 0, 0]: 0.0
Prediction for [0, 1, 0, 0, 0, 0, 0, 1]: 0.0
Prediction for [0, 1, 0, 0, 0, 0, 1, 0]: 1.0035794665731315
Prediction for [0, 1, 0, 0, 0, 0, 1, 1]: 0.0
Prediction for [0, 1, 0, 0, 0, 1, 0, 0]: 0.0
Prediction for [0, 1, 0, 0, 0, 1, 0, 1]: 0.994112527256279
Prediction for [0, 1, 0, 0, 0, 1, 1, 0]: 0.0
Prediction for [0, 1, 0, 0, 0, 1, 1, 1]: 0.0
Prediction for [0, 1, 0, 0, 1, 0, 0, 0]: 1.0118613803981313
Prediction for [0, 1, 0, 0, 1, 0, 0, 1]: 0.0
Prediction for [0, 1, 0, 0, 1, 0, 1, 0]: 0.0
Prediction for [0, 1, 0, 0, 1, 0, 1, 1]: 0.9847468032479805
Prediction for [0, 1, 0, 0, 1, 1, 0, 0]: 0.0
Prediction for [0, 1, 0, 0, 1, 1, 0, 1]: 0.0
Prediction for [0, 1, 0, 0, 1, 1, 1, 0]: 1.0151860264890478
Prediction for [0, 1, 0, 0, 1, 1, 1, 1]: 0.024533106135900873
Prediction for [0, 1, 0, 1, 0, 0, 0, 0]: 0.0
Prediction for [0, 1, 0, 1, 0, 0, 0, 1]: 1.0080674607462212
Prediction for [0, 1, 0, 1, 0, 0, 1, 0]: 0.0024421401257046504
Prediction for [0, 1, 0, 1, 0, 0, 1, 1]: 0.0
Prediction for [0, 1, 0, 1, 0, 1, 0, 0]: 1.014429925095659
Prediction for [0, 1, 0, 1, 0, 1, 0, 1]: 0.012388465701141271
Prediction for [0, 1, 0, 1, 0, 1, 1, 0]: 0.0
Prediction for [0, 1, 0, 1, 0, 1, 1, 1]: 1.0015320893551833
Prediction for [0, 1, 0, 1, 1, 0, 0, 0]: 0.0
Prediction for [0, 1, 0, 1, 1, 0, 0, 1]: 0.008986893723130773
Prediction for [0, 1, 0, 1, 1, 0, 1, 0]: 0.988894984198776
Prediction for [0, 1, 0, 1, 1, 0, 1, 1]: 0.0
Prediction for [0, 1, 0, 1, 1, 1, 0, 0]: 0.0
Prediction for [0, 1, 0, 1, 1, 1, 0, 1]: 0.9895108627880509
Prediction for [0, 1, 0, 1, 1, 1, 1, 0]: 0.0
Prediction for [0, 1, 0, 1, 1, 1, 1, 1]: 0.0
Prediction for [0, 1, 1, 0, 0, 0, 0, 0]: 1.009825663213511
Prediction for [0, 1, 1, 0, 0, 0, 0, 1]: 0.0
Prediction for [0, 1, 1, 0, 0, 0, 1, 0]: 0.0
Prediction for [0, 1, 1, 0, 0, 0, 1, 1]: 0.9969831815053549
Prediction for [0, 1, 1, 0, 0, 1, 0, 0]: 0.0
Prediction for [0, 1, 1, 0, 0, 1, 0, 1]: 0.0
Prediction for [0, 1, 1, 0, 0, 1, 1, 0]: 1.0109661178659124
Prediction for [0, 1, 1, 0, 0, 1, 1, 1]: 0.0
Prediction for [0, 1, 1, 0, 1, 0, 0, 0]: 3.412585478788088E-4
Prediction for [0, 1, 1, 0, 1, 0, 0, 1]: 1.0048969950754518
Prediction for [0, 1, 1, 0, 1, 0, 1, 0]: 0.0
Prediction for [0, 1, 1, 0, 1, 0, 1, 1]: 0.0
Prediction for [0, 1, 1, 0, 1, 1, 0, 0]: 1.0021185883167973
Prediction for [0, 1, 1, 0, 1, 1, 0, 1]: 0.0
Prediction for [0, 1, 1, 0, 1, 1, 1, 0]: 0.0
Prediction for [0, 1, 1, 0, 1, 1, 1, 1]: 0.9933752855728635
Prediction for [0, 1, 1, 1, 0, 0, 0, 0]: 0.0
Prediction for [0, 1, 1, 1, 0, 0, 0, 1]: 0.0
Prediction for [0, 1, 1, 1, 0, 0, 1, 0]: 1.0282356842581613
Prediction for [0, 1, 1, 1, 0, 0, 1, 1]: 0.0
Prediction for [0, 1, 1, 1, 0, 1, 0, 0]: 0.005941201595739631
Prediction for [0, 1, 1, 1, 0, 1, 0, 1]: 0.99620809778544
Prediction for [0, 1, 1, 1, 0, 1, 1, 0]: 0.0
Prediction for [0, 1, 1, 1, 0, 1, 1, 1]: 0.0
Prediction for [0, 1, 1, 1, 1, 0, 0, 0]: 0.8931867967531621
Prediction for [0, 1, 1, 1, 1, 0, 0, 1]: 0.0
Prediction for [0, 1, 1, 1, 1, 0, 1, 0]: 0.0
Prediction for [0, 1, 1, 1, 1, 0, 1, 1]: 1.0150169212393112
Prediction for [0, 1, 1, 1, 1, 1, 0, 0]: 0.0
Prediction for [0, 1, 1, 1, 1, 1, 0, 1]: 0.0
Prediction for [0, 1, 1, 1, 1, 1, 1, 0]: 0.9625024391184702
Prediction for [0, 1, 1, 1, 1, 1, 1, 1]: 0.0
Prediction for [1, 0, 0, 0, 0, 0, 0, 0]: 0.001812562085037328
Prediction for [1, 0, 0, 0, 0, 0, 0, 1]: 1.0075820389166497
Prediction for [1, 0, 0, 0, 0, 0, 1, 0]: 0.0
Prediction for [1, 0, 0, 0, 0, 0, 1, 1]: 0.0021364805521089103
Prediction for [1, 0, 0, 0, 0, 1, 0, 0]: 1.0029599045528612
Prediction for [1, 0, 0, 0, 0, 1, 0, 1]: 0.0
Prediction for [1, 0, 0, 0, 0, 1, 1, 0]: 0.0
Prediction for [1, 0, 0, 0, 0, 1, 1, 1]: 0.9904451241415937
Prediction for [1, 0, 0, 0, 1, 0, 0, 0]: 0.0037297400166580452
Prediction for [1, 0, 0, 0, 1, 0, 0, 1]: 0.0
Prediction for [1, 0, 0, 0, 1, 0, 1, 0]: 0.9868293608071959
Prediction for [1, 0, 0, 0, 1, 0, 1, 1]: 0.0
Prediction for [1, 0, 0, 0, 1, 1, 0, 0]: 0.0
Prediction for [1, 0, 0, 0, 1, 1, 0, 1]: 1.0005750703927658
Prediction for [1, 0, 0, 0, 1, 1, 1, 0]: 0.0
Prediction for [1, 0, 0, 0, 1, 1, 1, 1]: 0.0
Prediction for [1, 0, 0, 1, 0, 0, 0, 0]: 0.978185223696475
Prediction for [1, 0, 0, 1, 0, 0, 0, 1]: 0.0
Prediction for [1, 0, 0, 1, 0, 0, 1, 0]: 0.0
Prediction for [1, 0, 0, 1, 0, 0, 1, 1]: 0.996672418245852
Prediction for [1, 0, 0, 1, 1, 0, 0, 0]: 0.0
Prediction for [1, 0, 0, 1, 1, 0, 0, 1]: 1.0098078328385265
Prediction for [1, 0, 0, 1, 1, 0, 1, 0]: 0.02614965193375296
Prediction for [1, 0, 0, 1, 1, 0, 1, 1]: 0.0
Prediction for [1, 0, 0, 1, 1, 1, 0, 0]: 1.021506800445949
Prediction for [1, 0, 0, 1, 1, 1, 0, 1]: 0.0
Prediction for [1, 0, 0, 1, 1, 1, 1, 0]: 0.0
Prediction for [1, 0, 0, 1, 1, 1, 1, 1]: 0.9905850685320421
Prediction for [1, 0, 1, 0, 0, 0, 0, 0]: 0.0
Prediction for [1, 0, 1, 0, 0, 0, 0, 1]: 0.026291252638558138
Prediction for [1, 0, 1, 0, 0, 0, 1, 0]: 0.9941147588590282
Prediction for [1, 0, 1, 0, 0, 0, 1, 1]: 0.0
Prediction for [1, 0, 1, 0, 0, 1, 0, 0]: 0.0
Prediction for [1, 0, 1, 0, 0, 1, 0, 1]: 1.009095066550013
Prediction for [1, 0, 1, 0, 0, 1, 1, 0]: 0.0
Prediction for [1, 0, 1, 0, 0, 1, 1, 1]: 0.0
Prediction for [1, 0, 1, 0, 1, 0, 0, 0]: 0.9663028405728395
Prediction for [1, 0, 1, 0, 1, 0, 0, 1]: 0.0
Prediction for [1, 0, 1, 0, 1, 0, 1, 0]: 0.02919126024439267
Prediction for [1, 0, 1, 0, 1, 0, 1, 1]: 0.9847873421545761
Prediction for [1, 0, 1, 0, 1, 1, 0, 0]: 0.0
Prediction for [1, 0, 1, 0, 1, 1, 0, 1]: 0.0
Prediction for [1, 0, 1, 0, 1, 1, 1, 0]: 0.9970769942890474
Prediction for [1, 0, 1, 0, 1, 1, 1, 1]: 0.0
Prediction for [1, 0, 1, 1, 0, 0, 0, 0]: 0.01585487948672304
Prediction for [1, 0, 1, 1, 0, 0, 0, 1]: 0.9825434600642078
Prediction for [1, 0, 1, 1, 0, 0, 1, 0]: 5.733499619120508E-5
Prediction for [1, 0, 1, 1, 0, 0, 1, 1]: 0.0
Prediction for [1, 0, 1, 1, 0, 1, 0, 0]: 0.9745718337150491
Prediction for [1, 0, 1, 1, 0, 1, 0, 1]: 0.0
Prediction for [1, 0, 1, 1, 0, 1, 1, 0]: 0.02243720460008225
Prediction for [1, 0, 1, 1, 0, 1, 1, 1]: 0.9907022446975686
Prediction for [1, 0, 1, 1, 1, 0, 0, 0]: 0.012388250171380122
Prediction for [1, 0, 1, 1, 1, 0, 0, 1]: 0.0
Prediction for [1, 0, 1, 1, 1, 0, 1, 0]: 0.8601439621258544
Prediction for [1, 0, 1, 1, 1, 0, 1, 1]: 0.008443715075368896
Prediction for [1, 0, 1, 1, 1, 1, 0, 0]: 0.00656092875897496
Prediction for [1, 0, 1, 1, 1, 1, 0, 1]: 0.9780745437644223
Prediction for [1, 0, 1, 1, 1, 1, 1, 0]: 0.0
Prediction for [1, 0, 1, 1, 1, 1, 1, 1]: 0.0
Prediction for [1, 1, 0, 0, 0, 0, 0, 0]: 0.970924857927824
Prediction for [1, 1, 0, 0, 0, 0, 0, 1]: 0.0
Prediction for [1, 1, 0, 0, 0, 0, 1, 0]: 0.0
Prediction for [1, 1, 0, 0, 0, 0, 1, 1]: 1.0052769644182953
Prediction for [1, 1, 0, 0, 0, 1, 0, 0]: 0.0
Prediction for [1, 1, 0, 0, 0, 1, 0, 1]: 0.0
Prediction for [1, 1, 0, 0, 0, 1, 1, 0]: 0.9590540526744582
Prediction for [1, 1, 0, 0, 0, 1, 1, 1]: 0.02927320097632702
Prediction for [1, 1, 0, 0, 1, 0, 0, 0]: 0.0
Prediction for [1, 1, 0, 0, 1, 0, 0, 1]: 1.0035538352746003
Prediction for [1, 1, 0, 0, 1, 0, 1, 0]: 0.0
Prediction for [1, 1, 0, 0, 1, 0, 1, 1]: 0.0
Prediction for [1, 1, 0, 0, 1, 1, 0, 0]: 0.9909433633924776
Prediction for [1, 1, 0, 0, 1, 1, 0, 1]: 0.0
Prediction for [1, 1, 0, 0, 1, 1, 1, 0]: 0.0011777992274741855
Prediction for [1, 1, 0, 0, 1, 1, 1, 1]: 0.993085311255697
Prediction for [1, 1, 0, 1, 0, 0, 0, 0]: 0.0
Prediction for [1, 1, 0, 1, 0, 0, 0, 1]: 0.0
Prediction for [1, 1, 0, 1, 0, 0, 1, 0]: 0.9963515065208348
Prediction for [1, 1, 0, 1, 0, 0, 1, 1]: 0.0
Prediction for [1, 1, 0, 1, 0, 1, 0, 0]: 0.0
Prediction for [1, 1, 0, 1, 0, 1, 0, 1]: 0.9877397234933212
Prediction for [1, 1, 0, 1, 0, 1, 1, 0]: 0.0
Prediction for [1, 1, 0, 1, 0, 1, 1, 1]: 0.0
Prediction for [1, 1, 0, 1, 1, 0, 0, 0]: 0.9929770959632833
Prediction for [1, 1, 0, 1, 1, 0, 0, 1]: 0.0
Prediction for [1, 1, 0, 1, 1, 0, 1, 0]: 0.0
Prediction for [1, 1, 0, 1, 1, 0, 1, 1]: 0.9943824528184289
Prediction for [1, 1, 0, 1, 1, 1, 0, 0]: 0.0
Prediction for [1, 1, 0, 1, 1, 1, 0, 1]: 0.0
Prediction for [1, 1, 0, 1, 1, 1, 1, 0]: 0.9861277557175328
Prediction for [1, 1, 0, 1, 1, 1, 1, 1]: 0.0
Prediction for [1, 1, 1, 0, 0, 0, 0, 0]: 0.0
Prediction for [1, 1, 1, 0, 0, 0, 0, 1]: 0.9818293603820227
Prediction for [1, 1, 1, 0, 0, 0, 1, 0]: 0.0
Prediction for [1, 1, 1, 0, 0, 0, 1, 1]: 0.004688849263500661
Prediction for [1, 1, 1, 0, 0, 1, 0, 0]: 1.0032522995944633
Prediction for [1, 1, 1, 0, 0, 1, 0, 1]: 0.0
Prediction for [1, 1, 1, 0, 0, 1, 1, 0]: 0.0
Prediction for [1, 1, 1, 0, 0, 1, 1, 1]: 0.9705504218666294
Prediction for [1, 1, 1, 0, 1, 0, 0, 0]: 0.0
Prediction for [1, 1, 1, 0, 1, 0, 0, 1]: 0.0
Prediction for [1, 1, 1, 0, 1, 0, 1, 0]: 1.0079339023459069
Prediction for [1, 1, 1, 0, 1, 0, 1, 1]: 0.0
Prediction for [1, 1, 1, 0, 1, 1, 0, 0]: 0.0018277217158573222
Prediction for [1, 1, 1, 0, 1, 1, 0, 1]: 0.9965352241074292
Prediction for [1, 1, 1, 0, 1, 1, 1, 0]: 0.0
Prediction for [1, 1, 1, 0, 1, 1, 1, 1]: 0.0
Prediction for [1, 1, 1, 1, 0, 0, 0, 0]: 1.0369556161258267
Prediction for [1, 1, 1, 1, 0, 0, 0, 1]: 0.0
Prediction for [1, 1, 1, 1, 0, 0, 1, 0]: 0.015679304778673853
Prediction for [1, 1, 1, 1, 0, 0, 1, 1]: 0.9786961004714962
Prediction for [1, 1, 1, 1, 0, 1, 0, 0]: 0.0
Prediction for [1, 1, 1, 1, 0, 1, 0, 1]: 0.0
Prediction for [1, 1, 1, 1, 0, 1, 1, 0]: 1.0181741748672017
Prediction for [1, 1, 1, 1, 0, 1, 1, 1]: 0.0
Prediction for [1, 1, 1, 1, 1, 0, 0, 0]: 0.0
Prediction for [1, 1, 1, 1, 1, 0, 0, 1]: 0.9848654370142089
Prediction for [1, 1, 1, 1, 1, 0, 1, 0]: 0.04328380465776327
Prediction for [1, 1, 1, 1, 1, 0, 1, 1]: 0.0
Prediction for [1, 1, 1, 1, 1, 1, 0, 0]: 0.9962928146061278
Prediction for [1, 1, 1, 1, 1, 1, 0, 1]: 0.0
Prediction for [1, 1, 1, 1, 1, 1, 1, 0]: 0.0
Prediction for [1, 1, 1, 1, 1, 1, 1, 1]: 1.0215433789014763
BUILD SUCCESSFUL (total time: 20 seconds)
                                           
                                           
                                           

 

Edited by Dietmar
Link to comment
Share on other sites

15 hours ago, Dietmar said:

...Now I understand, how Neural Network learns and make some "predictions"

Hello @Dietmar, i'm back again.

You shurely did observe what happened with it's prediction for 11010 (26) above: that's really stupid, and later predictions get worse again and again. Not my taste of learning <_<

Maybe you should give it a try in tertiary number system!?:buehehe:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...