Пример #1
0
        public static void PreparePerceptionLayerForPulse(NeuralNet net, double[] input)
        {
            int i;

            if (input.Length != net.m_inputLayer.Count)
            {
                throw new ArgumentException(string.Format("Expecting {0} inputs for this net", net.m_inputLayer.Count));
            }

            // initialize data
            for (i = 0; i < net.m_inputLayer.Count; i++)
            {
                net.m_inputLayer[i].Output = input[i];
            }
        }
Пример #2
0
        private static void Initialize(NeuralNet net, int randomSeed,
                                       int inputNeuronCount, int hiddenNeuronCount, int outputNeuronCount, IActivationFunction aktivationFunction)
        {
            int    i, j;
            Random rand;

            rand = new Random(randomSeed);


            net.m_inputLayer  = new NeuralLayer();
            net.m_outputLayer = new NeuralLayer();
            net.m_hiddenLayer = new NeuralLayer();

            for (i = 0; i < inputNeuronCount; i++)
            {
                net.m_inputLayer.Add(new Neuron(0, aktivationFunction));
            }

            for (i = 0; i < outputNeuronCount; i++)
            {
                net.m_outputLayer.Add(new Neuron(rand.NextDouble(), aktivationFunction));
            }

            for (i = 0; i < hiddenNeuronCount; i++)
            {
                net.m_hiddenLayer.Add(new Neuron(rand.NextDouble(), aktivationFunction));
            }

            // wire-up input layer to hidden layer
            for (i = 0; i < net.m_hiddenLayer.Count; i++)
            {
                for (j = 0; j < net.m_inputLayer.Count; j++)
                {
                    net.m_hiddenLayer[i].Input.Add(net.m_inputLayer[j], new NeuralFactor(rand.NextDouble()));
                }
            }

            // wire-up output layer to hidden layer
            for (i = 0; i < net.m_outputLayer.Count; i++)
            {
                for (j = 0; j < net.m_hiddenLayer.Count; j++)
                {
                    net.m_outputLayer[i].Input.Add(net.HiddenLayer[j], new NeuralFactor(rand.NextDouble()));
                }
            }
        }