-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAndroidServer.java
More file actions
31 lines (25 loc) · 848 Bytes
/
AndroidServer.java
File metadata and controls
31 lines (25 loc) · 848 Bytes
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
import java.io.IOException;
import io.bhagat.ai.supervised.NeuralNetwork;
import io.bhagat.math.Function;
import io.bhagat.server.Server;
import io.bhagat.server.Server.ConnectionIndex;
import io.bhagat.util.SerializableUtil;
public class AndroidServer {
public static void main(String[] args) throws ClassNotFoundException, IOException {
Server server = new Server(2000, 10);
NeuralNetwork neuralNetwork;
neuralNetwork = SerializableUtil.deserialize("network.ser");
server.setCallback(new Function<ConnectionIndex, Object>() {
@Override
public Object f(ConnectionIndex x) {
double[] outputs = neuralNetwork.feedForward((double[]) x.getObject());
Integer guess = 0;
for(int i = 1; i < outputs.length; i++)
if(outputs[i] > outputs[guess])
guess = i;
return guess;
}
});
server.start();
}
}