Künstliche Intelligenz mit Java
Maschinelles Lernen mit Neuronalen Netzwerken

Die entsprechenden Forward-Pass-Formeln lauten wie folgt:

yh1 = x1*w1h1 + x2*w2h1 + b1

yh2 = x1*w1h2 + x2*w2h2 + b1

yo1 = yh1*w1o1 + yh2*w2o1 + b2 = output1 (as sum)

yo2 = yh1*w1o2 + yh2*w2o2 + b2 = output2 (as sum)

Und er schreibt (*Q25):
“For the rest of this tutorial we’re going to work with a single training set: given inputs 0.05 and 0.10, we want the neural network to output 0.01 and 0.99.” 

Zusätzlich werden sogar die Gewichte vorgegeben, die genauso wie die inputs und die targets hier in dem Maschine-Learning-Projekt in der Klasse VeryShortData gespeichert werden:

public class VeryShortData {

  // source: https://mattmazur.com/2015/03/17/a-step-by-step-backpropagation-example/

  public static final double[][] inputs = {
    { 0.05, 0.1 } };

  public static final double[][] targets = {
    { 0.01, 0.99 } };

  public static final double[][] weightsOfHiddenLayer = {
    { 0.15, 0.2, 0.35 },
    { 0.25, 0.3, 0.35 } };

  public static final double[][] weightsOfOutputLayer = {
    { 0.4, 0.45, 0.6 },
    { 0.5, 0.55, 0.6 } };

}

Im Endeffekt soll mit dem zweiten Beispiel überprüft werden, ob die Implementierung des Backpropagation-Algorithmus hier in diesem OpenBook die mathematisch richtigen Ergebnisse liefert. Wer sich in die Tiefen der Mathematik begeben will (z. B. Auszubildende in der Fachrichtung Mathematisch-Technischer Software-Entwickler), der sollte Matts Blog-Beitrag lesen.

public class TrainingParameter {

  public static final int numberOfEpochs = 1;
  public static final double learningRate = 0.5;
  public static final ActivationFunction activationFunction = ActivationFunction.SIGMOID;
  public static final double faultTolerance = 0.1;
  public static final double[][] inputs = VeryShortData.inputs;
  public static final double[][] targets = VeryShortData.targets;
  public static final double[][] weightsOfHiddenLayer = VeryShortData.weightsOfHiddenLayer;
  public static final double[][] weightsOfOutputLayer = VeryShortData.weightsOfOutputLayer;
  public static final boolean isBiasBackPropagationDesired = false;

}

- 53 -