public NeuralNet(NeuronMode mode, bool evolveActivationThreshold, int inputCount, int outputCount, int middleCount, int hiddenLayerCount) { this.mode = mode; inputLayer = new InputLayer(inputCount); outputLayer = new NeuronLayer(mode, outputCount, defaultActivationThreshold, evolveActivationThreshold); NeuronLayer prevLayer = null; for (int i = 0; i < hiddenLayerCount; ++i) { NeuronLayer newLayer = new NeuronLayer(mode, middleCount, defaultActivationThreshold, evolveActivationThreshold); hiddenLayers.Add(newLayer); if (prevLayer != null) { prevLayer.setOutputLayer(newLayer); } prevLayer = newLayer; } if (prevLayer != null) { prevLayer.setOutputLayer(outputLayer); inputLayer.setOutputLayer(hiddenLayers[0]); } else { inputLayer.setOutputLayer(outputLayer); } }
public NeuronLayer(NeuronMode mode, int neuronCount, double activationThreshold, bool evolveActivationThreshold) { for (int i = 0; i < neuronCount; ++i) { if (mode == NeuronMode.NEURON) { neuronList.Add(new Neuron(activationThreshold, evolveActivationThreshold)); } else if (mode == NeuronMode.PERCEPTRON) { neuronList.Add(new Perceptron(activationThreshold, evolveActivationThreshold)); } } }