1 package yawn.nn.appart;
2
3 import yawn.nn.Layer;
4 import yawn.nn.NeuralNode;
5 import yawn.util.Pattern;
6
7 /***
8 * A recognition (F2) layer gain control.
9 *
10 * <p>$Id: GainControlUnitOnMatching.java,v 1.10 2005/05/09 11:04:55 supermarti Exp $</p>
11 *
12 * @author Luis Martí (luis dot marti at uc3m dot es)
13 * @version $Revision: 1.10 $
14 */
15 public class GainControlUnitOnMatching extends GainControlUnit {
16
17 /***
18 *
19 * @uml.property name="adjunct"
20 * @uml.associationEnd multiplicity="(1 1)"
21 */
22 protected Layer adjunct;
23
24 /***
25 *
26 * @uml.property name="match"
27 */
28 protected boolean match;
29
30 /***
31 *
32 * @uml.property name="rho"
33 */
34 protected double rho;
35
36 /***
37 *
38 * @uml.property name="rhoMin"
39 */
40 protected double rhoMin;
41
42
43 public GainControlUnitOnMatching(double val, Layer l) {
44 rho = val;
45 rhoMin = val;
46 adjunct = l;
47 match = false;
48
49 }
50
51 public boolean fires() {
52 return !match;
53 }
54
55 /***
56 *
57 * @uml.property name="rho"
58 */
59 public double getVigilanceParameter() {
60 return rho;
61 }
62
63 /***
64 *
65 * @uml.property name="rhoMin"
66 */
67 public double getBaseVigilanceParameter() {
68 return rhoMin;
69 }
70
71
72 public void minimumActivationMatchTracking() {
73 NeuralNode[] nodes = adjunct.getNodes();
74
75 double newVigilance = Double.MAX_VALUE;
76
77 for (int i = 0; i < nodes.length; i++) {
78 if ((nodes[i].output() != 0)
79 && ((RadialBasisFunctionsNeuralNode) (nodes[i])).bigG() < newVigilance) {
80 newVigilance = ((RadialBasisFunctionsNeuralNode) (nodes[i])).bigG();
81 }
82
83 }
84 setVigilanceParameter(newVigilance);
85 }
86
87 public void oneShotMatchTracking() {
88 NeuralNode[] nodes = adjunct.getNodes();
89 Pattern v = ((RecognitionLayer) adjunct).getNormalizedActivations();
90
91 double aux = 0.0;
92
93 for (int i = 0; i < nodes.length; i++) {
94 aux += v.getComponent(i) * ((RadialBasisFunctionsNeuralNode) (nodes[i])).netInput();
95 }
96 aux = java.lang.Math.exp(aux / -2);
97 setVigilanceParameter(aux);
98 }
99
100 /***
101 *
102 * @uml.property name="match"
103 */
104 public void setMatch(boolean b) {
105 match = b;
106 }
107
108 /***
109 *
110 * @uml.property name="rho"
111 */
112 public void setVigilanceParameter(double val) {
113 rho = val;
114 NeuralNode[] nodes = adjunct.getNodes();
115 for (int i = 0; i < nodes.length; i++) {
116 if (nodes[i] != null) {
117 ((RadialBasisFunctionsNeuralNode) (nodes[i])).setThreshold(val);
118 }
119 }
120 }
121
122 }