View Javadoc

1   package yawn.nn.gasart;
2   
3   import java.util.ArrayList;
4   
5   import yawn.nn.Layer;
6   import yawn.nn.appart.GainControlUnitOnMatching;
7   import yawn.nn.appart.PredictionLayer;
8   import yawn.nn.appart.RecognitionLayer;
9   
10  /***
11   * A GasART recognition (F2) layer
12   * 
13   * <p>$Id: GasRecognitionLayer.java,v 1.9 2005/04/20 18:55:16 supermarti Exp $</p>
14   * 
15   * @author Luis Mart&iacute; (luis dot marti at uc3m dot es)
16   * @version $Revision: 1.9 $
17   */
18  public class GasRecognitionLayer extends RecognitionLayer {
19  
20      public GasRecognitionLayer(Layer nextLayer, GainControlUnitOnMatching g, int i) {
21          super(nextLayer, g, i);
22      }
23  
24      public void learn() {
25          if (!isAdapting())
26              return;
27      }
28  
29      public ArrayList getUnits() {
30          return units;
31      }
32  
33      public void deleteCategory(GasRecognitionNode unit) {
34          getUnits().remove(unit);
35      }
36  
37      /***
38       * does nothing
39       * 
40       */
41      public void calculateNormalizedActivations() {
42          return;
43      }
44  
45      public void makeNewCategory() {
46          units
47                  .add(new GasRecognitionNode(inputSize, g.getBaseVigilanceParameter(),
48                          units.size() + 1));
49      }
50  
51      public void matching() {
52          double aux;
53          g.setMatch(false);
54          for (int i = 0; i < size(); i++) {
55              aux = ((GasRecognitionNode) units.get(i)).output();
56              if (g.getVigilanceParameter() < aux) {
57                  ((GasRecognitionNode) units.get(i)).setActivation(aux);// /((classifierNeuralNode)Units.elementAt(i)).product();
58                  ((GasRecognitionNode) units.get(i)).setResetActivation(aux);
59                  g.setMatch(true);
60              } else {
61                  ((GasRecognitionNode) units.get(i)).setActivation(0.0);
62                  ((GasRecognitionNode) units.get(i)).setResetActivation(0.0);
63              }
64  
65          }// del for
66      }
67  
68      public void propagate() {
69          int to = nextLayer.size(), from = size();
70  
71          for (int i = 0; i < from; i++) {
72              for (int j = 0; j < to; j++)
73                  // if(((classifierNeuralNode)Units.elementAt(i)).activation>0)
74                  (((PredictionLayer) nextLayer).getAUnits())[j].setInputElement(
75                          ((GasRecognitionNode) units.get(i)).getActivation(), i);
76              // if(((classifierNeuralNode)Units.elementAt(i)).activation>0)
77              ((PredictionLayer) nextLayer).getBUnit().setInputElement(
78                      ((GasRecognitionNode) units.get(i)).getActivation(), i);
79              // los if fueron necesarios para no perder tiempo
80              // mandando cero lo cual no aumenta la entrada neta
81              // pero los quite porque debo actualizar los lastIn a cero para que
82              // no sigan con los viejos
83          }
84      }
85  
86      /*
87       * la clase que controla y desarrolla el algoritmo sera la que tendra en su
88       * learn ,que mandar a los determinados elementos de unit de esta capa,a que
89       * aprendan y no la misma capa
90       */
91  
92  }