NN2

by SwampFall

JavaScript

function Perceptron() {
	this.value = 0;
}

function Weight() {
	this.value = Math.random();
}

function Layer(size) {
	this.nodes = [];
  this.weights = [];
  for (var i = 0; i < size; i++) {
  	this.nodes.push(new Perceptron());
    this.weights.push(new Weight());
  }
}

function Network(layers) {
	this.learningRate = 0.1;
  this.layers = [];
  for (var i = 0; i < layers.length; i++) {
  	this.layers.push(layers[i]);
  }
  this.input = this.layers[0];
  this.output = this.layers[this.layers.length - 1];
}