Example #1
0
 //Constructs a layer of neurons and initializes them with the number of weights and the activation function to be uses.
 public NeuronLayer(int Neurons, int WeightsPerNeuron, Neuron.ActivationFunction ActivationFunction)
 {
     int idx = 0;
     Neuron n = null;
     for (idx = 0; idx <= Neurons - 1; idx++) {
         n = new Neuron(WeightsPerNeuron, ActivationFunction);
         List.Add(n);
     }
     mWeightsPerNeuron = WeightsPerNeuron;
 }
Example #2
0
 //Creates a neural network.
 //Inputs: The number of neurons in the input layer
 //Outputs: The number of neurons in the output layer
 //HiddenLayers:  The number of Hidden layers in the network.  This can be 0 or greater.
 //NeuronsPerHiddenLayer:  The number of neurons in each hidden layer.
 //InputWeightSize:  The number of weights in the input layer.  The weights size for each layer above is the number of neurons in the previous layer.
 //ActivationFunction:  The activation function to use in the neuron.
 public NeuralNetwork(int Inputs, int Outputs, int HiddenLayers, int NeuronsPerHiddenLayer, int InputWeightSize, Neuron.ActivationFunction Activation)
 {
     mInputLayer = new NeuronLayer(Inputs, InputWeightSize + 1, Activation);
     mLayers = new ArrayList();
     int idx = 0;
     int LastLayerSize = Inputs;
     for (idx = 0; idx <= HiddenLayers - 1; idx++) {
         mLayers.Add(new NeuronLayer(NeuronsPerHiddenLayer, LastLayerSize + 1, Activation));
         LastLayerSize = NeuronsPerHiddenLayer;
     }
     mOutputLayer = new NeuronLayer(Outputs, LastLayerSize + 1, Activation);
 }