Jump to content

Dietmar

Member
  • Posts

    1,124
  • Joined

  • Last visited

  • Days Won

    5
  • Donations

    0.00 USD 
  • Country

    Germany

Posts posted by Dietmar

  1. Hi,

    I make a new program with Java Netbeans, Ant.

    This one is much more intelligent in predicting the next number.

    It takes the whole input "number sequence" as the one and only thing, with which the Neural Network is trained.

    This means: Also the whole sequence in the numbers is stored for the learning process.

    I get a feeling, that not much more (!) can be done with Ai and this kind of Neural Network.

    Whole functions could be interpreted!!!

    One crazy thing I notice: Because of Normalization with 1000, small numbers give more bad results,

    dont know if the cause for this is the Sigmoid Function or just crazy round to zero by Java

    Dietmar

     

    package zahlen;
    
    import java.util.ArrayList;
    import java.util.Scanner;
    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;
    
    public class Zahlen {
        public static void main(String[] args) {
            ArrayList<Double> numbers = new ArrayList<>();
            Scanner scanner = new Scanner(System.in);
            boolean isInputActive = true;
    
            while (isInputActive) {
                String input = scanner.next();
                switch (input) {
                    case "list":
                        if (numbers.size() == 0) {
                            System.out.println("Die Liste ist leer.");
                        } else {
                            for (double number : numbers) {
                                System.out.println(number);
                            }
                        }
                        break;
                    case "q":
                        System.out.println("Eingabe beendet. Geben Sie 'quit' ein, um das Programm zu beenden, oder 'list', um die Liste der Zahlen anzuzeigen.");
                        break;
                    case "quit":
                        System.out.println("Das Programm wird beendet.");
                        isInputActive = false;
                        break;
                    default:
                        try {
                            double number = Double.parseDouble(input);
                            numbers.add(number / 1000.0);
                        } catch (NumberFormatException e) {
                            System.out.println("Ungültige Eingabe.");
                        }
                        break;
                }
            }
            scanner.close();
    
            int inputSize = numbers.size();
            int outputSize = 1;
    
            DataSet trainingSet = new DataSet(inputSize, outputSize);
    
            for (int i = 0; i < numbers.size() - 1; i++) {
                double[] inputArray = new double[numbers.size()];
                for (int j = 0; j < numbers.size(); j++) {
                    inputArray[j] = numbers.get(j);
                }
                double[] outputArray = new double[]{numbers.get(i+1)};
                trainingSet.add(new DataSetRow(inputArray, outputArray));
            }
    
            // create neural network
            NeuralNetwork neuralNet = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, inputSize, 300, 300,300,300,300,300,300, outputSize);
            // train the neural network
            neuralNet.learn(trainingSet);
    
            // use the trained neural network to predict the next number in the sequence
            double[] inputArray = new double[numbers.size()];
            for (int j = 0; j < numbers.size(); j++) {
                inputArray[j] = numbers.get(j);
            }
            neuralNet.setInput(inputArray);
            neuralNet.calculate();
            double[] predictedOutput = neuralNet.getOutput();
    
            // scale the predicted output back up to its original range
            double predictedNumber = predictedOutput[0] * 1000.0;
    
            // print the predicted output
            System.out.println("Das nächste Element könnte sein: " + predictedNumber);
        }
    }

     

  2. @TheFighterJetDude

    The acpi.sys build from Sources for XP SP3 is more stable on newer compis, than the acpi.sys from Sources for Bit64 XP.

    On the Gigabyte z690 UD DDR4 the Bios update helps a lot.

    But anyway, to work with Bios is a risk for whole compi.

    I "succeed" 2 times, that after correct Bios update compi was "dead", one time even with BiosFlashBack,

    Dietmar

  3. @TheFighterJetDude

    Disable in Device Manager the HID device, that is not your USB mouse.

    As you can see on my photo, I did the same. This HID device is for the LED control of the motherboard and it crashes your compi,

    as it did with all my z690 boards and I get report from other users with z690 or z790 boards about the same crash with this strange HID device

    Dietmar

  4. Yesssa:cheerleader::cheerleader::cheerleader:,

    I have the prove:

    The name Tima was first interpreted as "Hund" dog.

    But after training, Tima was first interpreted as "Katze" cat. I never tell the program, that Tima is the name of a cat.

    This means: Machines can learn things, that they have never done before.

    They can do more, than the programmer told them.

    A year ago, I would tell everybody, that this is nonsense.

    But the little, nice program above teach me, that I was wrong

    Dietmar

  5. Next version of this nice Ai program,

    where now you can see, that it learns.

    My next test of this program here will be, if after training, NEW words are correct at once, which have been done before wrong.

    I mean words, that the program has never seen before and during first test get a (n). Now, if all works as expected, the same word should get a (j) after training on first try.

    This behavior, if it happens, I would say is pur Intelligence. For example, the program can learn, if this is a name for a dog or for a cat.

    Not seen before those names.

    This program looks, if a user put in via keyboard a dog (Hund) or cat (Katze) or other (nix).

    This input words are all stored.

    When you type "liste", the list of all until now via keyboard transported words are listed.

    AND: If they are correct (j) or wrong (n) interpreted from Ai. In next step, when you correct Ai (n) ==> (j) always.

    Oh, just now I try different names for dogs and cats for example "Bello" and "Tima"

    Dietmar

     

    package tiere;
    
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Scanner;
    
    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;
    
    public class Tiere {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            NeuralNetwork<?> neuralNetwork = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, 26, 20, 20, 3);
            DataSet trainingSet = new DataSet(26, 3);
            Map<String, String> bewertungen = new HashMap<>();
            Map<String, String> antworten = new HashMap<>();
    
            while (true) {
                System.out.println("Gib ein Wort ein:");
                String eingabe = scanner.nextLine().toLowerCase();
    
                if (eingabe.equals("liste")) {
                    for (String wort : bewertungen.keySet()) {
                        String bewertung = bewertungen.get(wort);
                        String antwort = antworten.get(wort);
                        System.out.println(wort + ": " + bewertung + " (" + antwort + ")");
                    }
                    continue;
                }
    
                double[] input = createInputVector(eingabe);
                neuralNetwork.setInput(input);
                neuralNetwork.calculate();
    
                double[] output = neuralNetwork.getOutput().clone();
                String ergebnis = bestimmeErgebnis(output);
    
                System.out.println("Das Programm schätzt, dass es sich um " + ergebnis + " handelt.");
    
                System.out.println("War das Ergebnis korrekt? (Ja/Nein)");
                String antwort = scanner.nextLine().toLowerCase();
                antworten.put(eingabe, antwort);
                if (antwort.startsWith("n")) {
                    double[] gewünschteAusgabe = new double[3];
                    System.out.println("Um welches Tier handelt es sich korrekterweise? (Hund, Katze, nix)");
                    String tier = scanner.nextLine().toLowerCase();
                    switch (tier) {
                        case "hund":
                            gewünschteAusgabe[0] = 1;
                            break;
                        case "katze":
                            gewünschteAusgabe[1] = 1;
                            break;
                        default:
                            gewünschteAusgabe[2] = 1;
                            break;
                    }
    
                    DataSetRow trainingElement = new DataSetRow(input, gewünschteAusgabe);
                    trainingSet.add(trainingElement);
                    neuralNetwork.learn(trainingSet);
    
                    String bewertung = gewünschteAusgabe[0] == 1 ? "Hund" : gewünschteAusgabe[1] == 1 ? "Katze" : "nix";
                    bewertungen.put(eingabe, bewertung);
    
                    System.out.println("Das neuronale Netzwerk wurde aktualisiert.");
                } else {
                    String bewertung = ergebnis;
                    bewertungen.put(eingabe, bewertung);
                }
            }
        }
    
        // Hilfsmethode zum Erstellen des Eingabevektors
    private static double[] createInputVector(String eingabe) {
        double[] input = new double[26];
        for (int i = 0; i < eingabe.length(); i++) {
            char c = eingabe.charAt(i);
            if (c >= 'a' && c <= 'z') {
                input[c - 'a'] = 1;
            }
        }
        return input;
    }
    
    // Hilfsmethode zum Bestimmen des Ergebnisses aus der Ausgabe des Netzwerks
    private static String bestimmeErgebnis(double[] output) {
        if (output[0] > output[1] && output[0] > output[2]) {
            return "Hund";
        } else if (output[1] > output[0] && output[1] > output[2]) {
            return "Katze";
        } else {
            return "nix";
        }
    }
    }

     

  6. This is the same program via Ai, for to look only via keyboard, if an cat "Katze" or dog "Hund" or other "nix" ,that the human, who types the word, means.

    But now you can see all the new learned words, when you type "liste". The words, the Ai interprets correct in first try, are not in this list

    Dietmar

     

    package tiere;
    
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Scanner;
    
    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;
    
    public class Tiere {
    
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            NeuralNetwork<?> neuralNetwork = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, 26, 20, 20, 3);
            DataSet trainingSet = new DataSet(26, 3);
            Map<String, String> bewertungen = new HashMap<>(); // Neues Bewertungs-Dictionary
    
            while (true) {
                System.out.println("Gib ein Wort ein:");
                String eingabe = scanner.nextLine().toLowerCase();
    
                if (eingabe.equals("liste")) { // Wenn "liste" eingegeben wird
                    for (String wort : bewertungen.keySet()) {
                        System.out.println(wort + ": " + bewertungen.get(wort)); // Gib alle Bewertungen aus
                    }
                    continue;
                }
    
                double[] input = createInputVector(eingabe);
                neuralNetwork.setInput(input);
                neuralNetwork.calculate();
    
                double[] output = neuralNetwork.getOutput().clone();
                String ergebnis = bestimmeErgebnis(output);
    
                System.out.println("Das Programm schätzt, dass es sich um " + ergebnis + " handelt.");
    
                System.out.println("War das Ergebnis korrekt? (Ja/Nein)");
                String antwort = scanner.nextLine().toLowerCase();
                if (antwort.startsWith("j")) {
                    continue;
                }
    
                double[] gewünschteAusgabe = new double[3];
                System.out.println("Um welches Tier handelt es sich korrekterweise? (Hund, Katze, nix)");
                String tier = scanner.nextLine().toLowerCase();
                switch (tier) {
                    case "hund":
                        gewünschteAusgabe[0] = 1;
                        break;
                    case "katze":
                        gewünschteAusgabe[1] = 1;
                        break;
                    default:
                        gewünschteAusgabe[2] = 1;
                        break;
                }
    
                DataSetRow trainingElement = new DataSetRow(input, gewünschteAusgabe);
                trainingSet.add(trainingElement);
                neuralNetwork.learn(trainingSet);
    
                String bewertung = gewünschteAusgabe[0] == 1 ? "Hund" : gewünschteAusgabe[1] == 1 ? "Katze" : "nix";
                bewertungen.put(eingabe, bewertung); // Füge Bewertung zum Dictionary hinzu
    
                System.out.println("Das neuronale Netzwerk wurde aktualisiert.");
            }
        }
    
        // Hilfsmethode zum Erstellen des Eingabevektors
        private static double[] createInputVector(String eingabe) {
            double[] input = new double[26];
            for (int i = 0; i < eingabe.length(); i++) {
                char c = eingabe.charAt(i);
                if (c >= 'a' && c <= 'z') {
                    input[c - 'a'] = 1;
                }
            }
            return input;
        }
      
    // Hilfsmethode zum Bestimmen des Ergebnisses aus der Ausgabe des Netzwerks
    private static String bestimmeErgebnis(double[] output) {
        if (output[0] > output[1] && output[0] > output[2]) {
            return "Hund";
        } else if (output[1] > output[0] && output[1] > output[2]) {
            return "Katze";
        } else {
            return "nix";
        }
    }
    }

     

  7. Hi,

    after crazy hard work, now I make a programm, which can decide if it is "Hund" or "Katze" or "nix".

    And the program is crazy good learning, for example "Mausi" is now "Katze" but "Maus" is "nix"

    Dietmar

    PS:Until now, a lot of mistakes are in any program about Ai. But it can be done better. So we need to be afraid of Ai as much as possible.

    This small program shows ALL.

     

    package tiere;
    
    import java.util.Scanner;
    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;
    
    public class Tiere {
    
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            NeuralNetwork<?> neuralNetwork = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, 26, 20, 20, 3);
            DataSet trainingSet = new DataSet(26, 3);
    
            while (true) {
                System.out.println("Gib ein Wort ein:");
                String eingabe = scanner.nextLine().toLowerCase();
    
                double[] input = createInputVector(eingabe);
                neuralNetwork.setInput(input);
                neuralNetwork.calculate();
    
                double[] output = neuralNetwork.getOutput().clone();
                String ergebnis = bestimmeErgebnis(output);
    
                System.out.println("Das Programm schätzt, dass es sich um " + ergebnis + " handelt.");
    
                System.out.println("War das Ergebnis korrekt? (Ja/Nein)");
                String antwort = scanner.nextLine().toLowerCase();
                if (antwort.startsWith("j")) {
                    continue;
                }
    
                double[] gewünschteAusgabe = new double[3];
                System.out.println("Um welches Tier handelt es sich korrekterweise? (Hund, Katze, nix)");
                String tier = scanner.nextLine().toLowerCase();
                switch (tier) {
                    case "hund":
                        gewünschteAusgabe[0] = 1;
                        break;
                    case "katze":
                        gewünschteAusgabe[1] = 1;
                        break;
                    default:
                        gewünschteAusgabe[2] = 1;
                        break;
                }
    
                DataSetRow trainingElement = new DataSetRow(input, gewünschteAusgabe);
                trainingSet.add(trainingElement);
                neuralNetwork.learn(trainingSet);
    
                System.out.println("Das neuronale Netzwerk wurde aktualisiert.");
            }
        }
    
        // Hilfsmethode zum Erstellen des Eingabevektors
        private static double[] createInputVector(String eingabe) {
            double[] input = new double[26];
            for (int i = 0; i < eingabe.length(); i++) {
                char c = eingabe.charAt(i);
                if (c >= 'a' && c <= 'z') {
                    input[c - 'a'] = 1;
                }
            }
            return input;
        }
    
        // Hilfsmethode zum Bestimmen des Ergebnisses aus der Ausgabe des Netzwerks
        private static String bestimmeErgebnis(double[] output) {
            if (output[0] > output[1] && output[0] > output[2]) {
                return "Hund";
            } else if (output[1] > output[0] && output[1] > output[2]) {
                return "Katze";
            } else {
                return "nix";
            }
        }
    }
    

    Here is the Output. For me it is crazy, that "Bello" belongs to "Hund", this means, that the program is learning fast as much as possible.

    run:
    Gib ein Wort ein:
    nix
    Das Programm schätzt, dass es sich um nix handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    nixxxxxxxxxxxxxxx
    Das Programm schätzt, dass es sich um nix handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Kot
    Das Programm schätzt, dass es sich um nix handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    n
    Um welches Tier handelt es sich korrekterweise? (Hund, Katze, nix)
    Katze
    Das neuronale Netzwerk wurde aktualisiert.
    Gib ein Wort ein:
    Kot
    Das Programm schätzt, dass es sich um Katze handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Bulldogge
    Das Programm schätzt, dass es sich um Katze handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    n
    Um welches Tier handelt es sich korrekterweise? (Hund, Katze, nix)
    Hund
    Das neuronale Netzwerk wurde aktualisiert.
    Gib ein Wort ein:
    Bulldogge
    Das Programm schätzt, dass es sich um Hund handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Maunzi
    Das Programm schätzt, dass es sich um Hund handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    n
    Um welches Tier handelt es sich korrekterweise? (Hund, Katze, nix)
    Katze
    Das neuronale Netzwerk wurde aktualisiert.
    Gib ein Wort ein:
    Maunzi
    Das Programm schätzt, dass es sich um Katze handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Maunz
    Das Programm schätzt, dass es sich um Katze handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Hamster
    Das Programm schätzt, dass es sich um Katze handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    n
    Um welches Tier handelt es sich korrekterweise? (Hund, Katze, nix)
    nix
    Das neuronale Netzwerk wurde aktualisiert.
    Gib ein Wort ein:
    Hamster
    Das Programm schätzt, dass es sich um nix handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Tima
    Das Programm schätzt, dass es sich um Katze handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Boris
    Das Programm schätzt, dass es sich um nix handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    n
    Um welches Tier handelt es sich korrekterweise? (Hund, Katze, nix)
    Hund
    Das neuronale Netzwerk wurde aktualisiert.
    Gib ein Wort ein:
    Boris
    Das Programm schätzt, dass es sich um Hund handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Mieze
    Das Programm schätzt, dass es sich um Katze handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Köter
    Das Programm schätzt, dass es sich um Katze handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    n
    Um welches Tier handelt es sich korrekterweise? (Hund, Katze, nix)
    Hund
    Das neuronale Netzwerk wurde aktualisiert.
    Gib ein Wort ein:
    Köter
    Das Programm schätzt, dass es sich um Hund handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Dogge
    Das Programm schätzt, dass es sich um Hund handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Minna
    Das Programm schätzt, dass es sich um Katze handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:
    Bello
    Das Programm schätzt, dass es sich um Hund handelt.
    War das Ergebnis korrekt? (Ja/Nein)
    j
    Gib ein Wort ein:

  8. Hi,

    with Java Netbeans 16, Ant under XP SP3 I try to build a program, that can decide if it is a dog (Hund) or cat (Katze).

    Input is only via keyboard.

    But without success. Output gives always the same value, which means, that the program does not learn.

    Any idea, what i make wrong

    Dietmar

     

    package tiere;
    
    import java.util.Scanner;
    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;
    
    public class Tiere {
    
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            NeuralNetwork<?> neuralNetwork = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, 26, 20, 20, 1);
            DataSet trainingSet = new DataSet(26, 1);
    
            while (true) {
                System.out.println("Gib ein Wort ein:");
                String eingabe = scanner.nextLine().toLowerCase();
    
                double[] input = new double[26];
                for (int i = 0; i < eingabe.length(); i++) {
                    char c = eingabe.charAt(i);
                    if (c >= 'a' && c <= 'z') {
                        input[c - 'a'] = 1;
                    }
                }
    
                double[] output = new double[1];
                neuralNetwork.setInput(input);
               
                neuralNetwork.calculate();
    output = neuralNetwork.getOutput();
    System.out.println("Output: " + output[0]);
                
    
                String ergebnis = (output[0] < 0.5) ? "Hund" : "Katze";
                System.out.println("Das Programm schätzt, dass es sich um " + ergebnis + " handelt.");
    
                System.out.println("War das Ergebnis korrekt? (Ja/Nein)");
                String antwort = scanner.nextLine().toLowerCase();
                if (antwort.startsWith("j")) {
                    continue;
                }
    
                if (ergebnis.equals("Hund")) {
                    output[0] = 1;
                } else {
                    output[0] = 0;
                }
    
                DataSetRow trainingElement = new DataSetRow(input, output);
                trainingSet.add(trainingElement);
                neuralNetwork.learn(trainingSet);
    
                System.out.println("Das neuronale Netzwerk wurde aktualisiert.");
            }
        }
    }

     

×
×
  • Create New...