-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMLP.java
More file actions
47 lines (46 loc) · 1.08 KB
/
Copy pathMLP.java
File metadata and controls
47 lines (46 loc) · 1.08 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
import java.util.List;
import java.util.LinkedList;
public class MLP {
int nin;
int[] nouts;
int[] sz;
List<layer> layers;
Value val_x;
double[] double_x;
List<Value> params;
protected MLP(int nin,int[] nouts){
this.layers = new LinkedList<>();
int last_nout = nin;
for (int nout: nouts){
layer lay = new layer(last_nout,nout);
this.layers.add(lay);
last_nout = nout;
}
}
public List<layer> valu(){
return this.layers;
}
protected double[] call(double[] x){
double[] input = x;
for (layer lay: this.layers){
input = lay.call(x);
}
return input;
}
protected int len(List<Value> x){
int j = 1;
for(Value v: x){
j += 1;
}
return j;
}
protected List<Value> parameters(){
params = new LinkedList<>();
for (layer l: this.layers){
for (Value val: l.parameters()){
params.add(val);
}
}
return params;
}
}