Previous Entry Share Next Entry
I'm just waiting for the light to change
2012
unknownj
In between feeling wholly disillusioned with the entire education system, and being condescending to lecturers from universities that annoy me, I've also been working... I've been working on my Neural Networks stuff, and have thus far come up with a decent node object in Java, described here:

/**
 * Node for Neural Network
 */

public class nnode {

  private double bias = 0;
  private double[] value;
  private double[] weight;
  private int ninputs;
  private double ws = 0;

  public nnode(int indices, double thebias) {
    double[] value = new double[indices];
    double[] weight = new double[indices];
    ninputs = indices;
    bias = thebias;
  }

  public void setInput(int index, double vlu){
    if (ninputs > index && index > -1) {
      value[index] = weight[index] * vlu;
    }
  }

  public double getWeight(int index){
    if (ninputs > index && index > -1) {
      return weight[index];
    }
    return 0;
  }

  public void setWeight(int index, double vlu){
    if (ninputs > index && index > -1) {
      weight[index] = vlu;
    }
  }

  public double getBias(){
    return bias;
  }

  public void setBias(double thebias){
    bias = thebias;
  }

  public double getOutput(){
    for(int i = 0; i < ninputs; i++){
      ws = ws + value[i];
    }
    ws = ws + bias;
    return sigmoid(ws);
  }

  private double sigmoid(double input){
    double den = 1 + Math.exp(0 - input);
    double result = 1 / den;
    return result;
  }
}


Next I have to work on a way of holding all the nodes - a 3x4 two dimensional array should suffice perfectly. Once I've got that, then I can work on my training and learning algorithms, although I'm not sure how far I'll get through them.... Then I just have to write it up. Sounds easy..... right? ;o)

?

Log in

No account? Create an account