Exemple #1
0
        ///// <summary>
        ///// Funkcja y z definicji uzywana do modyfikacji wag neuronow radialnych
        ///// </summary>
        ///// <param name="fi"></param>
        ///// <returns></returns>
        //private double y(double[] xk)
        //{
        //    double result = 0;
        //    foreach( RadialNeuron neu in neuronHiddenLayer)
        //    {
        //        result += neu.fi(neu.u2(xk));
        //    }
        //    return result;
        //}

        /// <summary>
        /// Gradient funkcji gaussa wzgledem c
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        private double[] dE_dc(int nth_Output, int nth_Neuron)
        {
            double[]     result        = new double[documentList[0].GetValues().Count];
            RadialNeuron radialNeuron  = (RadialNeuron)neuronHiddenLayer[nth_Neuron];
            LinearNeuron linerarNeuron = (LinearNeuron)neuronOutputLayer[nth_Output];

            double[] inputVector;
            double   exp;

            //double maxValue;
            for (int wsp = 0; wsp < result.Length; wsp++)
            {
                for (int i = 0; i < documentList.Count; i++)              //learningData.DataVectors.Count
                {
                    inputVector  = documentList[i].GetValues().ToArray(); // learningData.InputVectors[i];
                    exp          = Math.Pow(Math.E, -radialNeuron.u2(inputVector) / 2);
                    result[wsp] += (y(linerarNeuron.Weights)[i] -
                                    (outputData[nth_Output])[i]) * linerarNeuron.Weights[nth_Neuron] *
                                   exp *radialNeuron.u(inputVector, wsp);

                    // Console.WriteLine(y(linerarNeuron.Weights)[i] + " - " +
                    //     (learningData.OutputVectors[nth_Output])[i]+ " = " + (y(linerarNeuron.Weights)[i] -
                    //     (learningData.OutputVectors[nth_Output])[i]));
                }
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Konstruktor neuronu o okreslonej strukturze
        /// </summary>
        /// <param name="hiddenLayerInitNeuronCount">liczba neuronow ukrytych</param>
        /// <param name="outputLayerNeuronCount">liczba neuronow wyjsciowych</param>
        public RadialNetwork(int hiddenLayerInitNeuronCount, int outputLayerNeuronCount)
        {
            neuronHiddenLayer        = new Collection <INeuron>();
            neuronOutputLayer        = new Collection <INeuron>();
            outputLayerNeutonWeights = new List <double[]>();
            for (int i = 0; i < hiddenLayerInitNeuronCount; i++)
            {
                INeuron r = new RadialNeuron();
                neuronHiddenLayer.Add(r);
            }

            for (int i = 0; i < outputLayerNeuronCount; i++)
            {
                INeuron r = new LinearNeuron();
                neuronOutputLayer.Add(r);
            }
        }