Repository navigation
Expand file tree
/
Copy pathNN.java
More file actions
63 lines (57 loc) · 1.86 KB
/
Copy pathNN.java
File metadata and controls
63 lines (57 loc) · 1.86 KB
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
59
60
61
62
63
import java.io.File;
import java.util.ArrayList;
import java.util.Random;
public class NN {
private ArrayList<Node> inputs;
private ArrayList<Node> outputs;
private ArrayList<Node[]> hiddenLayers;
public NN(ArrayList<Node> inputs, ArrayList<Node> outputs, int hiddenLayerCount) {
this.inputs = inputs;
this.outputs = outputs;
for (int i = 0; i < hiddenLayerCount; i++) {
Node[] hl = new Node[10];
hiddenLayers.add(hl);
}
Random r = new Random();
for (Node node : inputs) {
for (Node node2 : hiddenLayers.get(0)) {
Branch branch = new Branch(r.nextDouble(2)-1, node2, node);
}
}
for(int i = 0; i < hiddenLayers.size() - 2; i++) {
Node[] layer = hiddenLayers.get(i);
Node[] next = hiddenLayers.get(i+1);
for (Node node : layer) {
for (Node node2 : next) {
Branch branch = new Branch(r.nextDouble(2)-1, node2, node);
}
}
}
for (Node node1 : hiddenLayers.get(hiddenLayers.size()-1)) {
for (Node node2 : outputs) {
Branch branch = new Branch(r.nextDouble(2)-1, node2, node1);
}
}
}
public ArrayList<Node> getInputs() {
return inputs;
}
public void setInputs(ArrayList<Node> inputs) {
this.inputs = inputs;
}
public ArrayList<Node> getOutputs() {
return outputs;
}
public void setOutputs(ArrayList<Node> outputs) {
this.outputs = outputs;
}
public ArrayList<Node[]> getHiddenLayers() {
return hiddenLayers;
}
public void setHiddenLayers(ArrayList<Node[]> hiddenLayers) {
this.hiddenLayers = hiddenLayers;
}
public void runData(String imagepath) {
File f = new File(imagepath);
}
}