View Javadoc

1   package yawn.nn.appart;
2   
3   import yawn.nn.NeuralNode;
4   import yawn.util.Pattern;
5   
6   /***
7    * A prediction layer node. Receives as input the activation of the F2 layer, v.
8    * 
9    * <p>$Id: PredictionNeuralNode.java,v 1.11 2005/05/09 11:04:55 supermarti Exp $</p>
10   * 
11   * @author Luis Mart&iacute; (luis dot marti at uc3m dot es)
12   * @version $Revision: 1.11 $
13   */
14  
15  public class PredictionNeuralNode extends NeuralNode {
16  
17  	/***
18  	 * 
19  	 * @uml.property name="e" 
20  	 */
21  	protected double e;
22  
23  	/***
24  	 * 
25  	 * @uml.property name="weights"
26  	 * @uml.associationEnd multiplicity="(1 1)"
27  	 */
28  	protected Pattern weights;
29  
30  
31      PredictionNeuralNode(int inputSize, double e1) {
32          super(inputSize);
33          weights = new Pattern(inputSize);
34          e = e1;
35      }
36  
37      /***
38       * 
39       * @see yawn.nn.NeuralNode#activationFunction(yawn.util.Pattern)
40       */
41      protected double activationFunction(Pattern input) {
42          return weights.innerProduct(input);
43      }
44  
45  	/***
46  	 * @return the value of `e'
47  	 * 
48  	 * @uml.property name="e"
49  	 */
50  	public double getE() {
51  		return this.e;
52  	}
53  
54  
55      /***
56       * 
57       * @see yawn.nn.NeuralNode#getInputSize()
58       */
59      public int getInputSize() {
60          return weights.size();
61      }
62  
63  	/***
64  	 * @return the value
65  	 * 
66  	 * @uml.property name="weights"
67  	 */
68  	public Pattern getWeights() {
69  		return this.weights;
70  	}
71  
72  
73      void learn(double v_j) {
74          int m = weights.size();
75          for (int k = 0; k < m; k++) {
76              double aW = weights.getComponent(k);
77              double aLastIn = input.getComponent(k);
78              weights.setComponent(aW + (e * aLastIn * v_j), k);
79          }
80      }
81  
82  	/***
83  	 * @param e
84  	 * 
85  	 * @uml.property name="e"
86  	 */
87  	public void setE(double e) {
88  		this.e = e;
89  	}
90  
91  	/***
92  	 * @param weights
93  	 *            the weigths to set
94  	 * 
95  	 * @uml.property name="weights"
96  	 */
97  	public void setWeights(Pattern weights) {
98  		this.weights = weights;
99  	}
100 
101     /***
102      * 
103      * @param newInputFeature
104      * @param newWeightFeature
105      */
106     public void updateStructure(double newInputFeature, double newWeightFeature) {
107         inputSize++;
108         if (input != null) {
109             input.appendComponent(newInputFeature);
110         }
111         weights.appendComponent(newWeightFeature);
112     }
113 }