Dietmar Posted February 18, 2023 Posted February 18, 2023 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."); } } }
Dietmar Posted February 19, 2023 Author Posted February 19, 2023 (edited) 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: Edited February 19, 2023 by Dietmar
Dietmar Posted February 19, 2023 Author Posted February 19, 2023 (edited) 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"; } } } Edited February 19, 2023 by Dietmar
Dietmar Posted February 19, 2023 Author Posted February 19, 2023 (edited) 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"; } } } Edited February 19, 2023 by Dietmar
Dietmar Posted February 19, 2023 Author Posted February 19, 2023 Yesssa, 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
Dietmar Posted February 19, 2023 Author Posted February 19, 2023 Hi, can you give me 3 names for a cat and 3 names for a dog? Thanks a lot Dietmar
Dietmar Posted March 4, 2023 Author Posted March 4, 2023 (edited) 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); } } Edited March 5, 2023 by Dietmar 1
Mark-XP Posted March 19, 2023 Posted March 19, 2023 (edited) Hallo @Dietmar, coincidently i'was struggeling hardly the last days to get running a Java Dev setup here on my XP/32 bit machine. 12 years ago i've done my last (private, nice) Java project, with eclipse 3.5 (Galileo) and JDK/JRE 6.18! Nowadays it seems hardly feasable to create a portable, 32 bit setup of eclipse/Java, a true nightmare... Currently i'm stuck with combi Eclipse 4.9 x32 [Portable] and OpenJDK Temurin Portable 32-bit - unfortunately the latter seems to not work on XP-32... Now, latest netbeans portable that i find is version 8.0... Did you get your Netbeans 16(32bit) from here? Hopefully i can finally manage to get a working Java-IDE here the next days and join and participate your interesting topic here, until now it sadly was more a monologue hope to be able to change that soon... Edited March 19, 2023 by Mark-XP
Dietmar Posted March 19, 2023 Author Posted March 19, 2023 @Mark-XP Here is Netbeans 16 and Java 8.151 . First install Java under XP SP3. Then, you only have to look for netbeans.exe Dietmar https://ufile.io/cdsnn01j 1
Mark-XP Posted March 19, 2023 Posted March 19, 2023 Many thanks @Dietmar, i downloaded that package! Since i'm somwahar compulsive, i first have to try to reanimate my old project with eclipse and best portable. In Win7/64 i have a success both, Eclipse and Java (OpenJDK64) portable. It's nice to see Oracle's Java running caged within another process (see below). Now i have to see what's (versions) possible to run portable in XP/32, and later try out Netbeans - at the moment i'am not able to complie your Tierbeispiel.java above in eclipse/ant: imports from org.neuroph not resolved... until later! 1
Dietmar Posted March 19, 2023 Author Posted March 19, 2023 (edited) @Mark-XP Download neuroph 2.98 from here https://ufile.io/zpm08yru Extract it. Now comes the most most crazy part. Only this way works for me. Open in Netbeans above left on top "New Project". On next page choose "Java with Ant" and "Java Application". Nothing more, click "next". Type in "Project Name" in small letters "tiere". Green Mark is set for "Create Main Class" "tiere.Tiere" click finish. On the screen on the right side now delete all and after deleting all there, copy and paste whole "tiere" txt there. Now click on the left page "tiere" "Libraries". With right mouse click on "Libraries" and choose there "Add JAR/Folder", click on it with left mouse. Now search for your folder neuroph-2.98. Click on slf4 175 jar after this on slf4 176 jar visrec api 100 jar neuroph core 2.98 jar After this procedure, all Libraries that you need for the "tiere" program, are there, good luck Dietmar PS: May be there is a way to include all the Libraries from Neuroph into the Standard Libraries from Java. Until now, I di not succeed with it. So, for me only the way above works. Here is the whole tested code for "tiere" again. This program is crazy good and shows ALL, whatever an Artificial Intelligence can do at Maximum. No question, this is intelligent. I choose this program for to look for prim numbers, works. It has higher IQ than Chat GPT. 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("Ich schätze, dass es sich um " + ergebnis + " handelt."); System.out.println("War meine Antwort richtig? (Ja/Nein)"); String antwort = scanner.nextLine().toLowerCase(); antworten.put(eingabe, antwort); if (antwort.startsWith("n")) { double[] gewünschteAusgabe = new double[3]; System.out.println("Welches Tier ist es? (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("Ich habe etwas Neues dazugelernt."); } 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"; } } } Edited March 19, 2023 by Dietmar 1
Mark-XP Posted March 20, 2023 Posted March 20, 2023 (edited) Hi @Dietmar, latest (youngest) portable Eclipse/JDK combo i found (until now) is Eclipse 4.7.2 / Jportable 8u131. I could indeed reanimate my Börsen-chart project (unfortunately yahoo doesn't provide any marketdata any more).... Now i download the neuroph package (many thanks!), but then first want try to integrate it in eclipse (which i'm a little bit familiar with - netbeans would be another new IDE to learn and struggle with... ). Very curious about to experience AI live on my pc... until later! Edit: and the whole AI is packed to only 10 MB? Wow!!! Edited March 20, 2023 by Mark-XP 1
Mark-XP Posted March 20, 2023 Posted March 20, 2023 Hallo nochmal, @Dietmar, i was too curious: integration of neuroph-core seems ok, but first attempt to run your example ends with some errors, there's an unknown org/slf4j/LoggerFactory here... we'll see tomorrow, have to sleep now... 1
Mark-XP Posted March 20, 2023 Posted March 20, 2023 (edited) The problem resides in line 15 (also in latest eclipse/Java environment on Win7); NeuralNetwork<?> neuralNetwork = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, 26, 20, 20, 3); @Dietmar, could you please check if your tier-project imports something like org/slf4j? Edit: as far as i can see, all the knowlege you teach the AI in a session/run is lost then, and in each session it has to be trained newly from the scratch?! Wouldn't it be nice to implement - as a next step - to store all the learned things in a db? Edit2: i've found latest SLF4J API Module (2.0.7).jar, imported it to tier-project but error persists... error is solved! Edit3: next error, line 19 (DataSet trainingSet = new DataSet(26, 3);) causes ClassNotFoundException: javax.visrec.ml.data.DataSet . Try to resolve this... @Dietmar did you have this issues too, or is Netbeans simply better prepared than Eclipse?? Edited March 20, 2023 by Mark-XP Edit3 1
Dietmar Posted March 20, 2023 Author Posted March 20, 2023 (edited) @Mark-XP You do not integrate all Bibliotheks from Neuroph, that I mentioned. The message about error in logger I get only, when I try to implement the Neural Network from DeepLearning4J. There should be Maven better than Ant, because in Maven all needed dependencies are found automatically. May be, that the message about missing logger happens only in Eclipse. In Netbeans 16, I never saw this message with Neuroph. And yes, all the training data here are lost with restart. The only reason, why until now we do not need to be so much afraid about Ai is, that its brain consumes 10.000.000.000 more energy than ours. A quick calculation gives, that for a Human Brain with processors you need all the Power Plants from the whole USA. When you can store the training data and more important the weights for each neuron, you do not need to start at point zero each time the compi is turned on. For a single "n" from learning, ALL the weights have be set new. This you can see very easy at the memory ressources and the cpu power, that this nice Hund, Katze, nix program uses Dietmar Edited March 20, 2023 by Dietmar 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now