-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplicationRunner.java
More file actions
119 lines (91 loc) · 3.19 KB
/
ApplicationRunner.java
File metadata and controls
119 lines (91 loc) · 3.19 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;
/**
* Created by Srikanth on 2/27/2017.
*/
public class ApplicationRunner {
private static int hiddenLayerCount;
private static int hiddenLayerNodeCount;
private static float learningRate;
private static DataSet data;
private static int trainingSetLimit;
private static int datasetType;
public static void setTrainingSetLimit(int trainingSetLimit) {
ApplicationRunner.trainingSetLimit = trainingSetLimit;
}
public static void main(String[] args) {
//TODO Integrate with pre processing and construct neural network
learningRate = Float.parseFloat(args[1]);
hiddenLayerCount = Integer.parseInt(args[2]);
hiddenLayerNodeCount = Integer.parseInt(args[3]);
datasetType = Integer.parseInt(args[4]);
String datasetPath = String.valueOf(args[5]);
try {
run(datasetPath);
} catch (Exception e) {
e.printStackTrace();
}
trainingSetLimit = (int) (data.dataValues.size() * Integer.parseInt(args[0]) / 100);
NeuralNet network = new NeuralNet();
network.initializeNetwork();
// calculate the forward propagation of each layer and calculate all parameters
network.train();
network.test();
}
public static int getHiddenLayerCount() {
return hiddenLayerCount;
}
public static int getHiddenLayerNodeCount() {
return hiddenLayerNodeCount;
}
public static float getLearningRate() {
return learningRate;
}
public static DataSet getData() {
return data;
}
public static int getTrainingSetLimit() {
return trainingSetLimit;
}
public static int getDatasetType() {
return datasetType;
}
private static void run(String trainPath) throws InstantiationException, IllegalAccessException, IOException {
data = DataSet.parseTrainData(trainPath);
// DataSet testData = DataSet.parseTestFile(testPath);
List<Double> l1 = data.dataValues.get(0).attributes;
if (l1.size() == 15) {
data.normalize(1);
data.normalize(3);
data.normalize(5);
data.normalize(11);
data.normalize(12);
data.normalize(13);
} else if (l1.size() == 5) {
for (int i = 0; i < 4; i++)
data.normalize(i);
} else if (l1.size() == 14) {
for (int i = 0; i <= 2; i++) {
data.normalize(i);
}
for (int i = 4; i <= 7; i++)
data.normalize(i);
for (int i = 9; i <= 12; i++)
data.normalize(i);
}
/* //input value
for (int i = 0; i < data.dataValues.size(); i++) {
List l2 = data.dataValues.get(i).getAttributes();
for (int j = 0; j < l2.size(); j++)
System.out.println(l2.get(j));
}
//target value
int j = l1.size();
if (j == 13)
DataSet.parseTestData(j);
for (int k = 0; k < Data.a2.size(); k++)
System.out.println(Data.a2.get(k));*/
}
}