当前位置: 首页>>代码示例>>C#>>正文


C# BasicNetwork.GetLayerNeuronCount方法代码示例

本文整理汇总了C#中Encog.Neural.Networks.BasicNetwork.GetLayerNeuronCount方法的典型用法代码示例。如果您正苦于以下问题:C# BasicNetwork.GetLayerNeuronCount方法的具体用法?C# BasicNetwork.GetLayerNeuronCount怎么用?C# BasicNetwork.GetLayerNeuronCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Encog.Neural.Networks.BasicNetwork的用法示例。


在下文中一共展示了BasicNetwork.GetLayerNeuronCount方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RandomizeSynapse

        /// <summary>
        /// Randomize the connections between two layers.
        /// </summary>
        /// <param name="network">The network to randomize.</param>
        /// <param name="fromLayer">The starting layer.</param>
        private void RandomizeSynapse(BasicNetwork network, int fromLayer)
        {
            int toLayer = fromLayer + 1;
            int toCount = network.GetLayerNeuronCount(toLayer);
            int fromCount = network.GetLayerNeuronCount(fromLayer);
            int fromCountTotalCount = network.GetLayerTotalNeuronCount(fromLayer);
            IActivationFunction af = network.GetActivation(toLayer);
            double low = CalculateRange(af, Double.NegativeInfinity);
            double high = CalculateRange(af, Double.PositiveInfinity);

            double b = 0.7d * Math.Pow(toCount, (1d / fromCount)) / (high - low);

            for (int toNeuron = 0; toNeuron < toCount; toNeuron++)
            {
                if (fromCount != fromCountTotalCount)
                {
                    double w = RangeRandomizer.Randomize(-b, b);
                    network.SetWeight(fromLayer, fromCount, toNeuron, w);
                }
                for (int fromNeuron = 0; fromNeuron < fromCount; fromNeuron++)
                {
                    double w = RangeRandomizer.Randomize(0, b);
                    network.SetWeight(fromLayer, fromNeuron, toNeuron, w);
                }
            }
        }
开发者ID:jongh0,项目名称:MTree,代码行数:31,代码来源:NguyenWidrowRandomizer.cs

示例2: AnalyzeNetwork


//.........这里部分代码省略.........
         num12 = network.GetWeight(num3, num10, num11);
         goto Label_0127;
     }
     goto Label_00C3;
     Label_0115:
     values.Add(num12);
     num2++;
     if (0 == 0)
     {
         num11++;
         if (((uint) num9) < 0)
         {
             goto Label_02BF;
         }
         goto Label_00FF;
     }
     goto Label_0184;
     Label_0127:
     if (!network.Structure.ConnectionLimited)
     {
         goto Label_014B;
     }
     Label_0134:
     if (Math.Abs(num12) < network.Structure.ConnectionLimit)
     {
         num++;
         if ((((uint) num8) - ((uint) num12)) >= 0)
         {
             goto Label_0167;
         }
         goto Label_000B;
     }
     Label_014B:
     list.Add(num12);
     if ((((uint) num7) & 0) == 0)
     {
         goto Label_0115;
     }
     Label_0167:
     if ((((uint) num2) & 0) == 0)
     {
         goto Label_014B;
     }
     goto Label_0127;
     Label_0184:
     if (4 != 0)
     {
         goto Label_00C3;
     }
     goto Label_0057;
     Label_01E8:
     num11 = 0;
     goto Label_00FF;
     Label_01F2:
     num8++;
     Label_01F8:
     if (num8 < layerNeuronCount)
     {
         goto Label_02BF;
     }
     num7++;
     Label_0207:
     if (num7 < num4)
     {
         num8 = 0;
         goto Label_01F8;
     }
     if (((((uint) num8) | 1) != 0) && (num4 == layerTotalNeuronCount))
     {
         goto Label_0184;
     }
     num10 = num4;
     goto Label_01E8;
     Label_02BF:
     num9 = network.GetWeight(num3, num7, num8);
     if (0 == 0)
     {
         if (network.Structure.ConnectionLimited && (((((uint) num10) + ((uint) num)) < 0) || (Math.Abs(num9) < network.Structure.ConnectionLimit)))
         {
             num++;
         }
         list2.Add(num9);
     }
     values.Add(num9);
     num2++;
     goto Label_01F2;
     Label_0317:
     num4 = network.GetLayerNeuronCount(num3);
     layerTotalNeuronCount = network.GetLayerTotalNeuronCount(num3);
     if (((uint) num7) > uint.MaxValue)
     {
         goto Label_0134;
     }
     layerNeuronCount = network.GetLayerNeuronCount(num3 + 1);
     num7 = 0;
     if ((((uint) layerTotalNeuronCount) + ((uint) layerTotalNeuronCount)) >= 0)
     {
     }
     goto Label_0207;
 }
开发者ID:neismit,项目名称:emds,代码行数:101,代码来源:AnalyzeNetwork.cs

示例3: Randomize

        /// <summary>
        /// Randomize one level of a neural network.
        /// </summary>
        ///
        /// <param name="network">The network to randomize</param>
        /// <param name="fromLayer">The from level to randomize.</param>
        public override void Randomize(BasicNetwork network, int fromLayer)
        {
            int fromCount = network.GetLayerTotalNeuronCount(fromLayer);
            int toCount = network.GetLayerNeuronCount(fromLayer + 1);

            for (int fromNeuron = 0; fromNeuron < fromCount; fromNeuron++)
            {
                for (int toNeuron = 0; toNeuron < toCount; toNeuron++)
                {
                    double v = CalculateValue(toCount);
                    network.SetWeight(fromLayer, fromNeuron, toNeuron, v);
                }
            }
        }
开发者ID:Romiko,项目名称:encog-dotnet-core,代码行数:20,代码来源:FanInRandomizer.cs

示例4: FreeformNetwork

        /// <summary>
        /// Craete a freeform network from a basic network. 
        /// </summary>
        /// <param name="network">The basic network to use.</param>
        public FreeformNetwork(BasicNetwork network)
        {
            if (network.LayerCount < 2)
            {
                throw new FreeformNetworkError(
                    "The BasicNetwork must have at least two layers to be converted.");
            }

            // handle each layer
            IFreeformLayer previousLayer = null;

            for (int currentLayerIndex = 0;
                currentLayerIndex < network
                    .LayerCount;
                currentLayerIndex++)
            {
                // create the layer
                IFreeformLayer currentLayer = _layerFactory.Factor();

                // Is this the input layer?
                if (_inputLayer == null)
                {
                    _inputLayer = currentLayer;
                }

                // Add the neurons for this layer
                for (int i = 0; i < network.GetLayerNeuronCount(currentLayerIndex); i++)
                {
                    // obtain the summation object.
                    IInputSummation summation = null;

                    if (previousLayer != null)
                    {
                        summation = _summationFactory.Factor(network
                            .GetActivation(currentLayerIndex));
                    }

                    // add the new neuron
                    currentLayer.Add(_neuronFactory.FactorRegular(summation));
                }

                // Fully connect this layer to previous
                if (previousLayer != null)
                {
                    ConnectLayersFromBasic(network, currentLayerIndex - 1,
                        previousLayer, currentLayer);
                }

                // Add the bias neuron
                // The bias is added after connections so it has no inputs
                if (network.IsLayerBiased(currentLayerIndex))
                {
                    IFreeformNeuron biasNeuron = _neuronFactory
                        .FactorRegular(null);
                    biasNeuron.IsBias = true;
                    biasNeuron.Activation = network
                        .GetLayerBiasActivation(currentLayerIndex);
                    currentLayer.Add(biasNeuron);
                }

                // update previous layer
                previousLayer = currentLayer;
            }

            // finally, set the output layer.
            _outputLayer = previousLayer;
        }
开发者ID:benw408701,项目名称:MLHCTransactionPredictor,代码行数:71,代码来源:FreeformNetwork.cs

示例5: Randomize

        /// <summary>
        /// Randomize one level of a neural network.
        /// </summary>
        ///
        /// <param name="network">The network to randomize</param>
        /// <param name="fromLayer">The from level to randomize.</param>
        public virtual void Randomize(BasicNetwork network, int fromLayer)
        {
            int fromCount = network.GetLayerTotalNeuronCount(fromLayer);
            int toCount = network.GetLayerNeuronCount(fromLayer + 1);

            for (int fromNeuron = 0; fromNeuron < fromCount; fromNeuron++)
            {
                for (int toNeuron = 0; toNeuron < toCount; toNeuron++)
                {
                    double v = network.GetWeight(fromLayer, fromNeuron, toNeuron);
                    v = Randomize(v);
                    network.SetWeight(fromLayer, fromNeuron, toNeuron, v);
                }
            }
        }
开发者ID:benw408701,项目名称:MLHCTransactionPredictor,代码行数:21,代码来源:BasicRandomizer.cs

示例6: NetworkToString

        /// <summary>
        /// Format the network as a human readable string that lists the hidden
        /// layers.
        /// </summary>
        ///
        /// <param name="network">The network to format.</param>
        /// <returns>A human readable string.</returns>
        public static String NetworkToString(BasicNetwork network)
        {
            if (network != null)
            {
                var result = new StringBuilder();
                int num = 1;

                // display only hidden layers
                for (int i = 1; i < network.LayerCount - 1; i++)
                {
                    if (result.Length > 0)
                    {
                        result.Append(",");
                    }
                    result.Append("H");
                    result.Append(num++);
                    result.Append("=");
                    result.Append(network.GetLayerNeuronCount(i));
                }

                return result.ToString();
            }
            else
            {
                return "N/A";
            }
        }
开发者ID:Romiko,项目名称:encog-dotnet-core,代码行数:34,代码来源:PruneIncremental.cs

示例7: Randomize

        /// <summary>
        /// Randomize one level of a neural network.
        /// </summary>
        ///
        /// <param name="network">The network to randomize</param>
        /// <param name="fromLayer">The from level to randomize.</param>
        public override void Randomize(BasicNetwork network, int fromLayer)
        {
            int fromCount = network.GetLayerTotalNeuronCount(fromLayer);
            int toCount = network.GetLayerNeuronCount(fromLayer + 1);

            for (int toNeuron = 0; toNeuron < toCount; toNeuron++)
            {
                double n = 0.0;
                for (int fromNeuron = 0; fromNeuron < fromCount; fromNeuron++)
                {
                    double w = network.GetWeight(fromLayer, fromNeuron, toNeuron);
                    n += w * w;
                }
                n = Math.Sqrt(n);


                for (int fromNeuron = 0; fromNeuron < fromCount; fromNeuron++)
                {
                    double w = network.GetWeight(fromLayer, fromNeuron, toNeuron);
                    w = _beta * w / n;
                    network.SetWeight(fromLayer, fromNeuron, toNeuron, w);
                }
            }
        }
开发者ID:OperatorOverload,项目名称:encog-cs,代码行数:30,代码来源:NguyenWidrowRandomizer.cs

示例8: Randomize

 public override void Randomize(BasicNetwork network, int fromLayer)
 {
     int num2;
     int num3;
     double num4;
     int num5;
     double num6;
     int num7;
     double num8;
     int layerTotalNeuronCount = network.GetLayerTotalNeuronCount(fromLayer);
     goto Label_00DF;
     Label_0011:
     if (num3 < num2)
     {
         num4 = 0.0;
         num5 = 0;
     }
     else if ((((uint) num8) - ((uint) layerTotalNeuronCount)) >= 0)
     {
         return;
     }
     while (true)
     {
         if (num5 >= layerTotalNeuronCount)
         {
             num4 = Math.Sqrt(num4);
             num7 = 0;
             if ((((uint) num4) + ((uint) num2)) < 0)
             {
                 break;
             }
             goto Label_0065;
         }
         num6 = network.GetWeight(fromLayer, num5, num3);
         num4 += num6 * num6;
         num5++;
     }
     Label_0044:
     if ((((uint) fromLayer) + ((uint) num6)) > uint.MaxValue)
     {
         goto Label_00DF;
     }
     num7++;
     Label_0065:
     if (num7 < layerTotalNeuronCount)
     {
         num8 = network.GetWeight(fromLayer, num7, num3);
     }
     else
     {
         num3++;
         goto Label_0011;
     }
     Label_009C:
     num8 = (this._xd7d571ecee49d1e4 * num8) / num4;
     network.SetWeight(fromLayer, num7, num3, num8);
     goto Label_0044;
     Label_00DF:
     num2 = network.GetLayerNeuronCount(fromLayer + 1);
     if (((uint) num8) > uint.MaxValue)
     {
         goto Label_009C;
     }
     num3 = 0;
     goto Label_0011;
 }
开发者ID:neismit,项目名称:emds,代码行数:66,代码来源:NguyenWidrowRandomizer.cs

示例9: Randomize

 public override void Randomize(BasicNetwork network, int fromLayer)
 {
     int num4;
     double num5;
     int layerTotalNeuronCount = network.GetLayerTotalNeuronCount(fromLayer);
     int layerNeuronCount = network.GetLayerNeuronCount(fromLayer + 1);
     int fromNeuron = 0;
     if (((uint) fromLayer) < 0)
     {
         goto Label_0012;
     }
     Label_000E:
     if (fromNeuron < layerTotalNeuronCount)
     {
         num4 = 0;
         goto Label_0054;
     }
     Label_0012:
     if (((uint) num5) > uint.MaxValue)
     {
         goto Label_0054;
     }
     if ((((uint) fromNeuron) + ((uint) fromNeuron)) >= 0)
     {
         return;
     }
     Label_003C:
     num5 = this.x7417261f548b2c9b(layerNeuronCount);
     network.SetWeight(fromLayer, fromNeuron, num4, num5);
     num4++;
     Label_0054:
     if (num4 < layerNeuronCount)
     {
         goto Label_003C;
     }
     fromNeuron++;
     goto Label_000E;
 }
开发者ID:neismit,项目名称:emds,代码行数:38,代码来源:FanInRandomizer.cs

示例10: Randomize

 public virtual void Randomize(BasicNetwork network, int fromLayer)
 {
     int num4;
     double num5;
     int layerTotalNeuronCount = network.GetLayerTotalNeuronCount(fromLayer);
     int layerNeuronCount = network.GetLayerNeuronCount(fromLayer + 1);
     int fromNeuron = 0;
     goto Label_002C;
     Label_000D:
     fromNeuron++;
     if ((((uint) fromNeuron) + ((uint) fromNeuron)) > uint.MaxValue)
     {
         goto Label_004B;
     }
     if (0 != 0)
     {
         goto Label_003C;
     }
     Label_002C:
     if (fromNeuron < layerTotalNeuronCount)
     {
         goto Label_0067;
     }
     return;
     Label_003C:
     network.SetWeight(fromLayer, fromNeuron, num4, num5);
     num4++;
     Label_004B:
     if (num4 < layerNeuronCount)
     {
         num5 = network.GetWeight(fromLayer, fromNeuron, num4);
         if (((uint) num5) >= 0)
         {
             num5 = this.Randomize(num5);
             goto Label_003C;
         }
         goto Label_000D;
     }
     if ((((uint) fromLayer) + ((uint) fromLayer)) >= 0)
     {
         goto Label_000D;
     }
     Label_0067:
     num4 = 0;
     goto Label_004B;
 }
开发者ID:neismit,项目名称:emds,代码行数:46,代码来源:BasicRandomizer.cs

示例11: Learn

        public List<double[]> Learn(double[][] data, double[][] ideal)
        {
            double[][] origData = (double[][])data.Clone();
            int n = data.Length;
            int m = data[0].Length;
            double[][] output = new double[n][];
            double[][] sgmNeighbours = new double[n][];
            for (var i = 0; i < n; i++)
            {
                double[] sgmN = new double[SegmentationData.SEGMENT_NEIGHBOURS];
                Array.Copy(data[i], m - SegmentationData.SEGMENT_NEIGHBOURS, sgmN, 0, SegmentationData.SEGMENT_NEIGHBOURS);
                sgmNeighbours[i] = sgmN;
                data[i] = data[i].Take(m - SegmentationData.SEGMENT_NEIGHBOURS).ToArray();
                output[i] = new double[m - SegmentationData.SEGMENT_NEIGHBOURS];
                data[i].CopyTo(output[i], 0);
            }

            IMLDataSet trainingSet = new BasicMLDataSet(data, output);

            int inputLayerSize = layersConfiguration[0] - SegmentationData.SEGMENT_NEIGHBOURS;
            int trainingLayerSize = layersConfiguration[1];
            BasicNetwork oneLayerAutoencoder = new BasicNetwork();
            oneLayerAutoencoder.AddLayer(new BasicLayer(null, BIAS, inputLayerSize));
            oneLayerAutoencoder.AddLayer(new BasicLayer(CurrentActivationFunction(), BIAS, trainingLayerSize));
            oneLayerAutoencoder.AddLayer(new BasicLayer(CurrentActivationFunction(), false, inputLayerSize));
            oneLayerAutoencoder.Structure.FinalizeStructure();
            oneLayerAutoencoder.Reset();

            IMLTrain train = new ResilientPropagation(oneLayerAutoencoder, trainingSet);
            //IMLTrain train = new Backpropagation(oneLayerAutoencoder, trainingSet, LEARNING_RATE, MOMENTUM);

            int epoch = 1;
            List<double[]> errors = new List<double[]>();
            double[] trainError = new double[AUTOENCODER_MAX_ITER];

            do
            {
                train.Iteration();
                ActiveForm.Text = @"Epoch #" + epoch + @" Error:" + train.Error;
                Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                trainError[epoch - 1] = train.Error;
                epoch++;
                //errors.Add(train.Error);
            } while (train.Error > EPS && epoch < AUTOENCODER_MAX_ITER);
            errors.Add(trainError);
            train.FinishTraining();

            BasicNetwork encoder = new BasicNetwork();
            encoder.AddLayer(new BasicLayer(null, BIAS, oneLayerAutoencoder.GetLayerNeuronCount(0)));
            encoder.AddLayer(new BasicLayer(CurrentActivationFunction(), false, oneLayerAutoencoder.GetLayerNeuronCount(1)));
            encoder.Structure.FinalizeStructure();
            encoder.Reset();

            //przypisanie wag do encodera
            for (int i = 0; i < encoder.LayerCount - 1; i++)
                for (int f = 0; f < encoder.GetLayerNeuronCount(i); f++)
                    for (int t = 0; t < encoder.GetLayerNeuronCount(i + 1); t++)
                        encoder.SetWeight(i, f, t, oneLayerAutoencoder.GetWeight(i, f, t));

            //Compare2Networks(oneLayerAutoencoder, encoder);

            for(int l=1; l<layersConfiguration.Count -2; l++)
            {
                inputLayerSize = layersConfiguration[l];
                trainingLayerSize = layersConfiguration[l+1];
                oneLayerAutoencoder = new BasicNetwork();
                oneLayerAutoencoder.AddLayer(new BasicLayer(null, BIAS, inputLayerSize));
                oneLayerAutoencoder.AddLayer(new BasicLayer(CurrentActivationFunction(), BIAS, trainingLayerSize));
                oneLayerAutoencoder.AddLayer(new BasicLayer(CurrentActivationFunction(), false, inputLayerSize));
                oneLayerAutoencoder.Structure.FinalizeStructure();
                oneLayerAutoencoder.Reset();

                //liczenie outputu z dotychczasowego encodera
                double[][] input = new double[n][];
                double[][] newOutput = new double[n][];
                for(int ni = 0; ni <n; ni++)
                {
                    IMLData res = encoder.Compute(new BasicMLData(data[ni]));
                    double[] resD = new double[res.Count];
                    for(int i=0; i<res.Count; i++)
                        resD[i] = res[i];
                    input[ni] = resD;
                    newOutput[ni] = new double[res.Count];
                    input[ni].CopyTo(newOutput[ni], 0);
                }

                BasicMLDataSet newTrainingSet = new BasicMLDataSet(input, newOutput);
                train = new ResilientPropagation(oneLayerAutoencoder, newTrainingSet);
                //train = new Backpropagation(oneLayerAutoencoder, newTrainingSet, LEARNING_RATE, MOMENTUM);

                epoch = 1;
                trainError = new double[AUTOENCODER_MAX_ITER];
                do
                {
                    train.Iteration();
                    ActiveForm.Text = @"Epoch #" + epoch + @" Error:" + train.Error;
                    Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                    trainError[epoch - 1] = train.Error;
                    epoch++;
                } while (train.Error > EPS && epoch < AUTOENCODER_MAX_ITER);
//.........这里部分代码省略.........
开发者ID:matkaczmarski,项目名称:Neural-Network,代码行数:101,代码来源:AutoencoderWoCmp.cs

示例12: Compare2Networks

 private void Compare2Networks(BasicNetwork n1, BasicNetwork n2)
 {
     string oneLay = string.Empty;
     for (int i = 0; i < n1.LayerCount - 1; i++)
     {
         oneLay += ("Layer: " + i + ": \n");
         for (int f = 0; f < n1.GetLayerNeuronCount(i); f++)
         {
             oneLay += ("Neuron: " + f + "\n");
             for (int t = 0; t < n1.GetLayerNeuronCount(i + 1); t++)
             {
                 oneLay += (n1.GetWeight(i, f, t) + ", ");
             }
             oneLay += "\n";
         }
         oneLay += "\n";
     }
     oneLay += "---------------------------------------\n\n";
     for (int i = 0; i < n2.LayerCount - 1; i++)
     {
         oneLay += ("Layer: " + i + ": \n");
         for (int f = 0; f < n2.GetLayerNeuronCount(i); f++)
         {
             oneLay += ("Neuron: " + f + "\n");
             for (int t = 0; t < n2.GetLayerNeuronCount(i + 1); t++)
             {
                 oneLay += (n2.GetWeight(i, f, t) + ", ");
             }
             oneLay += "\n";
         }
         oneLay += "\n";
     }
     MessageBox.Show(oneLay);
 }
开发者ID:matkaczmarski,项目名称:Neural-Network,代码行数:34,代码来源:AutoencoderWoCmp.cs

示例13: NetworkToString

 public static string NetworkToString(BasicNetwork network)
 {
     if (network == null)
     {
         return "N/A";
     }
     StringBuilder builder = new StringBuilder();
     int num = 1;
     if (0 != 0)
     {
         goto Label_0039;
     }
     int l = 1;
     if ((((uint) l) - ((uint) l)) > uint.MaxValue)
     {
         goto Label_0021;
     }
     Label_000C:
     if (l < (network.LayerCount - 1))
     {
         if (builder.Length > 0)
         {
             builder.Append(",");
         }
     }
     else
     {
         if (0 != 0)
         {
             goto Label_000C;
         }
         return builder.ToString();
     }
     Label_0021:
     builder.Append("H");
     builder.Append(num++);
     Label_0039:
     builder.Append("=");
     builder.Append(network.GetLayerNeuronCount(l));
     l++;
     goto Label_000C;
 }
开发者ID:neismit,项目名称:emds,代码行数:42,代码来源:PruneIncremental.cs


注:本文中的Encog.Neural.Networks.BasicNetwork.GetLayerNeuronCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。