-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAndTesting.java
More file actions
37 lines (34 loc) · 1.44 KB
/
AndTesting.java
File metadata and controls
37 lines (34 loc) · 1.44 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
public class AndTesting implements TestingDevice {
private double learningRate;
private double desiredAccuracy;
private int hiddenNum;
private int learningEpochs;
private double testingAccuracy;
AndTesting(double learningRate, double desiredAccuracy, int hiddenNum) {
this.learningRate = learningRate;
this.desiredAccuracy = desiredAccuracy;
this.hiddenNum = hiddenNum;
System.out.println("And Digit Testing results: ");
System.out.println(" - " + hiddenNum + " hidden neurons");
System.out.println(" - " + "Learning rate of: " + learningRate);
System.out.println(" - " + "Validation threshold of: " + desiredAccuracy);
}
@Override
public void run () {
Example[] and = new Example[]{
new Example(new double[]{1, 1}, 1, 2),
new Example(new double[]{0, 0}, 0, 2),
new Example(new double[]{1, 0}, 0, 2),
new Example(new double[]{0, 1}, 0, 2)};
AviNeuralNet tester = new AviNeuralNet(2, hiddenNum, 2, learningRate);
learningEpochs = tester.learn(and, 1, desiredAccuracy);
testingAccuracy = tester.test(and);
}
@Override
public void displayResult() {
run();
System.out.println(" - Learning completed in " + learningEpochs + " epochs");
System.out.println(" - Final testing accuracy " + testingAccuracy);
System.out.println();
}
}