Exemple #1
0
        /// <summary>
        /// Calculates weights for the hopfield net to learn the specified training
        /// set
        /// </summary>
        /// <param name="trainingSet">
        ///            training set to learn </param>
        public override void learn(DataSet trainingSet)
        {
            int   M             = trainingSet.size();
            int   N             = neuralNetwork.getLayerAt(0).NeuronsCount;
            Layer hopfieldLayer = neuralNetwork.getLayerAt(0);

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if (j == i)
                    {
                        continue;
                    }
                    Neuron     ni  = hopfieldLayer.getNeuronAt(i);
                    Neuron     nj  = hopfieldLayer.getNeuronAt(j);
                    Connection cij = nj.getConnectionFrom(ni);
                    Connection cji = ni.getConnectionFrom(nj);
                    double     w   = 0;
                    for (int k = 0; k < M; k++)
                    {
                        DataSetRow trainingSetRow = trainingSet.getRowAt(k);
                        double     pki            = trainingSetRow.Input[i];
                        double     pkj            = trainingSetRow.Input[j];
                        w = w + pki * pkj;
                    }                     // k
                    cij.Weight.Value = w;
                    cji.Weight.Value = w;
                }         // j
            }             // i
        }
 private void createPromoLabels(Layer layer)
 {
     layer.getNeuronAt(0).Label = "Sales";
     layer.getNeuronAt(1).Label = "New";
     layer.getNeuronAt(2).Label = "Bestseller";
 }
 private void createPriceLabels(Layer layer)
 {
     layer.getNeuronAt(0).Label = "Low Price";
     layer.getNeuronAt(1).Label = "Mid Price";
     layer.getNeuronAt(2).Label = "High Price";
 }
 private void createBrandLabels(Layer layer)
 {
     layer.getNeuronAt(0).Label = "Samsung";
     layer.getNeuronAt(1).Label = "LG";
     layer.getNeuronAt(2).Label = "Sony";
 }
 private void createTypeLabels(Layer layer)
 {
     layer.getNeuronAt(0).Label = "LCD TV";
     layer.getNeuronAt(1).Label = "Digital Camera";
     layer.getNeuronAt(2).Label = "Mobile Phone";
 }
 private void createProductLabels(Layer layer)
 {
     layer.getNeuronAt(0).Label  = "Samsung LCD TV LE-32A330";
     layer.getNeuronAt(1).Label  = "Samsung LCD TV LE-32A558";
     layer.getNeuronAt(2).Label  = "LG LCD TV 32LG2000";
     layer.getNeuronAt(3).Label  = "LG LCD TV 32LG5010";
     layer.getNeuronAt(4).Label  = "Sony LCD TV KDL-32L4000K";
     layer.getNeuronAt(5).Label  = "Sony LCD TV KDL-32S4000";
     layer.getNeuronAt(6).Label  = "Sony LCD TV KDL-32W4000K";
     layer.getNeuronAt(7).Label  = "Samsung Digital Camera S760";
     layer.getNeuronAt(8).Label  = "Samsung Digital Camera L100";
     layer.getNeuronAt(9).Label  = "Samsung Digital Camera S850";
     layer.getNeuronAt(10).Label = "LG Digital Camera DMCLS80E";
     layer.getNeuronAt(11).Label = "LG Digital Camera DMCLZ8E";
     layer.getNeuronAt(12).Label = "Sony Digital Camera DSCW120S";
     layer.getNeuronAt(13).Label = "Sony Digital Camera DSCW130S";
     layer.getNeuronAt(14).Label = "Samsung Mobile Phone E251";
     layer.getNeuronAt(15).Label = "Samsung Mobile Phone U600";
     layer.getNeuronAt(16).Label = "Sony Mobile Phone KP100";
     layer.getNeuronAt(17).Label = "Sony Mobile Phone KE850";
     layer.getNeuronAt(18).Label = "LG Mobile Phone K330";
     layer.getNeuronAt(19).Label = "LG Mobile Phone K660";
 }