Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package cz.vsb.mro0010.neuralnetworks;
import java.util.ArrayList;
public abstract class MultiLayeredNet extends NeuralNet {
protected ArrayList<ArrayList<Neuron>> neuronLayers;
protected ArrayList<InputLayerPseudoNeuron> inputNeuronLayer;
protected int nrOfInputs;
protected int nrOfLayers;
protected ArrayList<Integer> nrOfNeuronsPerLayer;
public MultiLayeredNet(int nrOfInputs, int nrOfLayers, ArrayList<Integer> nrOfNeuronsPerLayer) {
super();
this.nrOfInputs = nrOfInputs;
this.nrOfLayers = nrOfLayers;
this.nrOfNeuronsPerLayer = nrOfNeuronsPerLayer;
neuronLayers = new ArrayList<ArrayList<Neuron>>(nrOfLayers);
inputNeuronLayer = new ArrayList<InputLayerPseudoNeuron>(nrOfInputs);
for (int i = 0; i < nrOfLayers; i++) {
neuronLayers.add(new ArrayList<Neuron>(nrOfNeuronsPerLayer.get(i)));
}
for (int i = 0; i < nrOfInputs; i++) {
inputNeuronLayer.add(new InputLayerPseudoNeuron());
}
}
public MultiLayeredNet() {
this(0,0,null);
}
public int getNrOfInputs() {
return nrOfInputs;
}
public int getNrOfLayers() {
return nrOfLayers;
}
@Override
public void run(String input) {
String[] inputValues = input.split(" ");
if (inputValues.length != nrOfInputs)
throw new InvalidInputNumberException();
for (int i = 0; i < nrOfInputs; i++) {
InputLayerPseudoNeuron in = this.inputNeuronLayer.get(i);
in.initialize();
in.adjustPotential(Float.parseFloat(inputValues[i]));
in.transfer();
}
for (int i = 0; i < nrOfLayers; i++) {
Interconnections interconnectionsLayer = interconnectionsLayers.get(i);
interconnectionsLayer.passSignal();
}
}
}