-
Notifications
You must be signed in to change notification settings - Fork 0
/
Neuron.java
61 lines (56 loc) · 1.17 KB
/
Neuron.java
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
package SOM;
import java.util.ArrayList;
public class Neuron {
private double outval;
private ArrayList <Connection> in=new ArrayList <Connection>();
private ArrayList <Connection> out=new ArrayList <Connection>();
private int x;
private int y;
public void SetPos(int a, int b){
x=a;
y=b;
}
public int[] GetPos(){
int[] pos={x,y};
return pos;
}
public void SetOut(double x){
outval=x;
}
public double GetOutVal(){
return outval;
}
public void AddIn(Connection x){
in.add(x);
}
public void AddOut(Connection x){
out.add(x);
}
public ArrayList <Connection> GetOut(){
return out;
}
public ArrayList <Connection> GetIn(){
return in;
}
public double GetNetSum(){
double netsum=0;
for(int i=0;i<in.size();i++){
netsum+=in.get(i).GetInp().GetOutVal();
}
return netsum;
}
public double[] GetInpValuesArray(){
double[] InpValues=new double[in.size()];
for(int i=0;i<in.size();i++){
InpValues[i]=in.get(i).GetInp().GetOutVal();
}
return InpValues;
}
public double[] GetInpWeightsArray(){
double[] InpWeights=new double[in.size()];
for(int i=0;i<in.size();i++){
InpWeights[i]=in.get(i).GetWeight();
}
return InpWeights;
}
}