1 package yawn.nn; 2 3 import yawn.util.Pattern; 4 5 /*** 6 * An abstract neural node. 7 * 8 * <p>$Id: NeuralNode.java,v 1.8 2005/05/09 11:04:58 supermarti Exp $</p> 9 * 10 * @author Luis Martí (luis dot marti at uc3m dot es) 11 * @version $Revision: 1.8 $ 12 */ 13 public abstract class NeuralNode { 14 15 /*** 16 * 17 * @uml.property name="input" 18 * @uml.associationEnd multiplicity="(0 1)" 19 */ 20 protected Pattern input; 21 22 /*** 23 * 24 * @uml.property name="inputSize" 25 */ 26 protected int inputSize; 27 28 /*** 29 * @param inputSize 30 * 31 * @uml.property name="inputSize" 32 */ 33 public void setInputSize(int inputSize) { 34 this.inputSize = inputSize; 35 } 36 37 /*** 38 * 39 * @uml.property name="inputSize" 40 */ 41 public int getInputSize() { 42 return inputSize; 43 } 44 45 46 public NeuralNode(int inputSize) { 47 this.inputSize = inputSize; 48 } 49 50 /*** 51 * resets the current activation. By default removes the current input. 52 */ 53 public void reset() { 54 input = null; 55 } 56 57 /*** 58 * sets the current input of the node 59 * 60 * @param val 61 * the input 62 * 63 * @uml.property name="input" 64 */ 65 public void setInput(Pattern val) { 66 input = new Pattern(inputSize); 67 input.setComponents(val); 68 } 69 70 public double output() { 71 return activationFunction(input); 72 } 73 74 protected abstract double activationFunction(Pattern input); 75 76 public void setInputElement(double val, int i) { 77 input.setComponent(val, i); 78 } 79 80 }