//Constructor public AxonLayer(NeuronLayer previousneuronlayer, NeuronLayer nextneuronlayer) { this.previousneuronlayer = previousneuronlayer; this.nextneuronlayer = nextneuronlayer; this.weights = Matrix.Random(nextneuronlayer.nbneurons, previousneuronlayer.nbneurons, 1.0 / Math.Sqrt(previousneuronlayer.nbneurons)); this.weightsupdate = new Matrix(nextneuronlayer.nbneurons, previousneuronlayer.nbneurons); }
//constructor for the other layers (builds all the links with the previous layer) public NeuronLayer(int nbneurons, NeuronLayer previousneuronlayer) { neuron_activation = new Vector(nbneurons); neuron_bias = Vector.Random(nbneurons, 1); this.biasupdate = new Vector(nbneurons); this.nbneurons = nbneurons; this.previousneuronlayer = previousneuronlayer; previousneuronlayer.nextneuronlayer = this; AxonLayer axonlayer = new AxonLayer(this.previousneuronlayer, this); this.previousaxonlayer = axonlayer; previousneuronlayer.nextaxonlayer = axonlayer; }
//Construct the network public Brain(Parameters parameters) { NeuronLayer.parameters = parameters; AxonLayer.parameters = parameters; int[] layerssize = parameters.layers_size; nblayers = layerssize.Length; layers = new NeuronLayer[nblayers]; layers[0] = new NeuronLayer(layerssize[0]); for (int i = 1; i < layerssize.Length; i++) { layers[i] = new NeuronLayer(layerssize[i], layers[i - 1]); } }