Ejemplo n.º 1
0
        //
        public NeuralNet(Topology topology, ActivationFunction activationFunction_, double alpha = 0.5, double eta = 0.15)
        {
            RandomSequence.Reset();
            numberLayers = topology.NumberLayers();
            if (numberLayers < 2)
            {
                throw new Exception("Number of layers should be at least 2");
            }

            layers = new Layer[numberLayers];
            ActivationFunction activationFunction = activationFunction_;

            for (int layerIdx = 0; layerIdx < numberLayers; layerIdx++)
            {
                int      nNeurons = topology.NumberNeuronsAtLayer(layerIdx);
                Neuron[] neurons  = new Neuron[nNeurons + 1];
                int      nOutputs = (layerIdx == numberLayers - 1 ? 0 : topology.NumberNeuronsAtLayer(layerIdx + 1));
                // Main neurons
                for (int neuronIdx = 0; neuronIdx < nNeurons + 1; neuronIdx++)
                {
                    neurons[neuronIdx] = new Neuron(nOutputs, neuronIdx, activationFunction, alpha, eta);
                }

                // Force the bias neuron's output value to 1.0
                neurons.Back().OutputValue = 1.0;

                layers[layerIdx] = new Layer(neurons);
            }
        }
Ejemplo n.º 2
0
 //
 public Connection()
 {
     Weight      = RandomSequence.DrawDouble();
     DeltaWeight = 0.0;
     //DeltaWeight = Constant.MACHINE_MAX;
 }