-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReader.pde
More file actions
45 lines (43 loc) · 1.18 KB
/
Reader.pde
File metadata and controls
45 lines (43 loc) · 1.18 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
//package com.javatpoint;
public class Reader {
void read(NeuralNetwork nn) {
try {
// use buffered reader to read line by line
BufferedReader reader = createReader("m1.txt");
int i;
String line = null;
for (i=0; i<nn.inputs; i++) {
for (int j=0; j<nn.hidden; j++){
line = reader.readLine();
nn.m1.data[i][j] = float(line);
}
}
reader = createReader("m2.txt");
for (i=0; i<nn.hidden; i++) {
for (int j=0; j<nn.outputs; j++){
line = reader.readLine();
nn.m2.data[i][j] = float(line);
}
}
}
catch (IOException e) {
println("Exception:" + e.toString());
}
}
void write(NeuralNetwork nn) {
PrintWriter output = createWriter("m1.txt");
for (int i=0; i<nn.inputs; i++) {
for (int j=0; j<nn.hidden; j++)
output.println(nn.m1.data[i][j]);
}
output.flush();
output.close();
output = createWriter("m2.txt");
for (int i=0; i<nn.hidden; i++) {
for (int j=0; j<nn.outputs; j++)
output.println(nn.m2.data[i][j]);
}
output.flush();
output.close();
}
}