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


C# BasicNetwork.AddLayer方法代码示例

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


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

示例1: Preprocessing_Completed

        private void Preprocessing_Completed(object sender, RunWorkerCompletedEventArgs e)
        {
            worker.ReportProgress(0, "Creating Network...");
            BasicNetwork Network = new BasicNetwork();
            Network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, DataContainer.NeuralNetwork.Data.InputSize));
            Network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 50));
            Network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, DataContainer.NeuralNetwork.Data.IdealSize));
            Network.Structure.FinalizeStructure();
            Network.Reset();
            DataContainer.NeuralNetwork.Network = Network;

            ResilientPropagation training = new ResilientPropagation(DataContainer.NeuralNetwork.Network, DataContainer.NeuralNetwork.Data);
            worker.ReportProgress(0, "Running Training: Epoch 0");
            for(int i = 0; i < 200; i++)
            {
                training.Iteration();
                worker.ReportProgress(0, "Running Training: Epoch " + (i+1).ToString() + "     Current Training Error : " + training.Error.ToString());
                if(worker.CancellationPending == true)
                {
                    completed = true;
                    return;
                }

            }
            completed = true;
        }
开发者ID:ebosscha,项目名称:RailML-Neural,代码行数:26,代码来源:PerLineClassification.cs

示例2: Run

        public override void Run()
        {
            testNetwork = new BasicNetwork();

            testNetwork.AddLayer(new BasicLayer(null, true, 2));
            testNetwork.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 4));
            testNetwork.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
            testNetwork.Structure.FinalizeStructure();
            testNetwork.Reset();

            // create training data
            IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);

            // train the neural network
            IMLTrain train = new Backpropagation(testNetwork, trainingSet);
            //IMLTrain train = new ResilientPropagation(testNetwork, trainingSet); //Encog manual says it is the best general one

            int epoch = 1;

            do
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                epoch++;
            } while (train.Error > 0.0001);

            // test the neural network
            Console.WriteLine(@"Neural Network Results:");
            foreach (IMLDataPair pair in trainingSet)
            {
                IMLData output = testNetwork.Compute(pair.Input);
                Console.WriteLine(pair.Input[0] + @"," + pair.Input[1]
                                  + @", actual=" + output[0] + @",ideal=" + pair.Ideal[0]);
            }
        }
开发者ID:mgcarmueja,项目名称:MPTCE,代码行数:35,代码来源:EncogTestContainer.cs

示例3: Execute

        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            // create a neural network, without using a factory
            var network = new BasicNetwork();
            network.AddLayer(new BasicLayer(null, true, 2));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
            network.Structure.FinalizeStructure();
            network.Reset();

            // create training data
            IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);

            // train the neural network
            IMLTrain train = new ResilientPropagation(network, trainingSet);

            int epoch = 1;

            do
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                epoch++;
            } while (train.Error > 0.01);

            // test the neural network
            Console.WriteLine(@"Neural Network Results:");
            foreach (IMLDataPair pair in trainingSet)
            {
                IMLData output = network.Compute(pair.Input);
                Console.WriteLine(pair.Input[0] + @"," + pair.Input[1]
                                  + @", actual=" + output[0] + @",ideal=" + pair.Ideal[0]);
            }
        }
开发者ID:johannsutherland,项目名称:encog-dotnet-core,代码行数:38,代码来源:XORHelloWorld.cs

示例4: Main

        static void Main(string[] args)
        {
            var network = new BasicNetwork();
            network.AddLayer(new BasicLayer(null, true, 2));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
            network.Structure.FinalizeStructure();
            network.Reset();

            var trainingSet = new BasicMLDataSet(XORInput, XORIdeal);
            var train = new ResilientPropagation(network, trainingSet);
            var epoch = 1;
            do
            {
                train.Iteration();

            } while (train.Error > 0.01);

            train.FinishTraining();

            foreach (var pair in trainingSet)
            {
                var output = network.Compute(pair.Input);
                Console.WriteLine(pair.Input[0] + @", " + pair.Input[1] + @" , actual=" + output[0] + @", ideal=" + pair.Ideal[0]);
            }

            EncogFramework.Instance.Shutdown();
            Console.ReadLine();
        }
开发者ID:akucherk,项目名称:HelloSystem,代码行数:29,代码来源:Program.cs

示例5: TestSingleOutput

        public void TestSingleOutput()
        {

            BasicNetwork network = new BasicNetwork();
            network.AddLayer(new BasicLayer(null, true, 2));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 2));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
            network.Structure.FinalizeStructure();

            (new ConsistentRandomizer(-1, 1)).Randomize(network);

            IMLDataSet trainingData = new BasicMLDataSet(XOR.XORInput, XOR.XORIdeal);

            HessianFD testFD = new HessianFD();
            testFD.Init(network, trainingData);
            testFD.Compute();

            HessianCR testCR = new HessianCR();
            testCR.Init(network, trainingData);
            testCR.Compute();

            //dump(testFD, "FD");
            //dump(testCR, "CR");
            Assert.IsTrue(testCR.HessianMatrix.equals(testFD.HessianMatrix, 4));
        }
开发者ID:JDFagan,项目名称:encog-dotnet-core,代码行数:25,代码来源:TestHessian.cs

示例6: BenchmarkEncog

        public static long BenchmarkEncog(double[][] input, double[][] output)
        {
            var network = new BasicNetwork();
            network.AddLayer(new BasicLayer(null, true,
                                            input[0].Length));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), true,
                                            HIDDEN_COUNT));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), false,
                                            output[0].Length));
            network.Structure.FinalizeStructure();
            network.Reset(23); // constant seed for repeatable testing

            IMLDataSet trainingSet = new BasicMLDataSet(input, output);

            // train the neural network
            IMLTrain train = new Backpropagation(network, trainingSet, 0.7, 0.7);

            var sw = new Stopwatch();
            sw.Start();
            // run epoch of learning procedure
            for (int i = 0; i < ITERATIONS; i++)
            {
                train.Iteration();
            }
            sw.Stop();

            return sw.ElapsedMilliseconds;
        }
开发者ID:johannsutherland,项目名称:encog-dotnet-core,代码行数:28,代码来源:SimpleBenchmark.cs

示例7: Main

        static void Main(string[] args)
        {
            //create a neural network withtout using a factory
            var network = new BasicNetwork();
            network.AddLayer(new BasicLayer(null, true, 2));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 2));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));

            network.Structure.FinalizeStructure();
            network.Reset();

            IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);
            IMLTrain train = new ResilientPropagation(network, trainingSet);

            int epoch = 1;
            do
            {
                train.Iteration();
                Console.WriteLine($"Epoch #{epoch} Error: {train.Error}");
                epoch++;
            } while (train.Error > 0.01);
            train.FinishTraining();

            Console.WriteLine("Neural Network Results:");
            foreach (IMLDataPair iPair in trainingSet)
            {
                IMLData output = network.Compute(iPair.Input);
                Console.WriteLine($"{iPair.Input[0]}, {iPair.Input[0]}, actual={output[0]}, ideal={iPair.Ideal[0]}");
            }

            EncogFramework.Instance.Shutdown();

            Console.ReadKey();
        }
开发者ID:zerazobz,项目名称:TestEncog,代码行数:34,代码来源:Program.cs

示例8: generateNetwork

 public BasicNetwork generateNetwork()
 {
     BasicNetwork network = new BasicNetwork();
     network.AddLayer(new BasicLayer(MultiThreadBenchmark.INPUT_COUNT));
     network.AddLayer(new BasicLayer(MultiThreadBenchmark.HIDDEN_COUNT));
     network.AddLayer(new BasicLayer(MultiThreadBenchmark.OUTPUT_COUNT));
     network.Structure.FinalizeStructure();
     network.Reset();
     return network;
 }
开发者ID:OperatorOverload,项目名称:encog-cs,代码行数:10,代码来源:MultiThreadBenchmark.cs

示例9: Create

 public void Create(int inputnodes,int hiddennodes)
 {
     network = new BasicNetwork();
     network.AddLayer(new BasicLayer(null, true, inputnodes));
     network.AddLayer(new BasicLayer(new ActivationTANH(), true, hiddennodes));
     network.AddLayer(new BasicLayer(new ActivationLinear(), false, 1));
     network.Structure.FinalizeStructure();
     network.Reset();
     this.hiddennodes = hiddennodes;
 }
开发者ID:bp1977,项目名称:MyEncog,代码行数:10,代码来源:NNet.cs

示例10: generateNetwork

 public BasicNetwork generateNetwork()
 {
     var network = new BasicNetwork();
     network.AddLayer(new BasicLayer(INPUT_COUNT));
     network.AddLayer(new BasicLayer(HIDDEN_COUNT));
     network.AddLayer(new BasicLayer(OUTPUT_COUNT));
     network.Structure.FinalizeStructure();
     network.Reset();
     return network;
 }
开发者ID:johannsutherland,项目名称:encog-dotnet-core,代码行数:10,代码来源:MultiThreadBenchmark.cs

示例11: CreateThreeLayerNet

 public static BasicNetwork CreateThreeLayerNet()
 {
     var network = new BasicNetwork();
     network.AddLayer(new BasicLayer(2));
     network.AddLayer(new BasicLayer(3));
     network.AddLayer(new BasicLayer(1));
     network.Structure.FinalizeStructure();
     network.Reset();
     return network;
 }
开发者ID:CreativelyMe,项目名称:encog-dotnet-core,代码行数:10,代码来源:XOR.cs

示例12: CreateNetwork

 /// <summary>
 /// Metodo responsavel por criar a rede neural
 /// </summary>
 /// <param name="source">FileInfo com o path do network</param>
 private static void CreateNetwork(FileInfo source)
 {
     var network = new BasicNetwork();
     network.AddLayer(new BasicLayer(new ActivationLinear(), true, 4));
     network.AddLayer(new BasicLayer(new ActivationTANH(), true, 6));
     network.AddLayer(new BasicLayer(new ActivationTANH(), false, 2));
     network.Structure.FinalizeStructure();
     network.Reset();
     EncogDirectoryPersistence.SaveObject(source, (BasicNetwork)network);
 }
开发者ID:itiroinazawa,项目名称:MachineLearning,代码行数:14,代码来源:ResilientPropagationClassification.cs

示例13: createElliott

 public static BasicNetwork createElliott()
 {
     BasicNetwork network = new BasicNetwork();
     network.AddLayer(new BasicLayer(null, true, INPUT_OUTPUT));
     network.AddLayer(new BasicLayer(new ActivationElliottSymmetric(), true, HIDDEN));
     network.AddLayer(new BasicLayer(new ActivationElliottSymmetric(), false, INPUT_OUTPUT));
     network.Structure.FinalizeStructure();
     network.Reset();
     return network;
 }
开发者ID:fxmozart,项目名称:encog-dotnet-core,代码行数:10,代码来源:ElliottBenchmark.cs

示例14: ConstructNetwork

 private BasicNetwork ConstructNetwork()
 {
     var network = new BasicNetwork();
     network.AddLayer(new BasicLayer(new ActivationTANH(), true, VanDerWaerdenGameRules.VanDerWaerdenNumber(this.NColors, this.ProgressionLength) - 1));
     network.AddLayer(new BasicLayer(new ActivationTANH(), true, VanDerWaerdenGameRules.VanDerWaerdenNumber(this.NColors, this.ProgressionLength)));
     network.AddLayer(new BasicLayer(new ActivationTANH(), true, 1));
     network.Structure.FinalizeStructure();
     return network;
     Debug.Print("Created new Network with parameters nColors = {0} and progression length = {1}.", NColors, ProgressionLength);
 }
开发者ID:JGrzybowski,项目名称:VanDerWaerdenGame,代码行数:10,代码来源:NeuralPositionPlayer1.cs

示例15: CreateNetwork

 public static void CreateNetwork(FileOps fileOps)
 {
     var network = new BasicNetwork();
     network.AddLayer(new BasicLayer(new ActivationLinear(),true,4));
     network.AddLayer(new BasicLayer(new ActivationTANH(), true, 6));
     network.AddLayer(new BasicLayer(new ActivationTANH(), true, 2));
     network.Structure.FinalizeStructure();
     network.Reset();
     EncogDirectoryPersistence.SaveObject(fileOps.TrainedNeuralNetworkFile, network);
 }
开发者ID:MacarioTala,项目名称:Learning-Machine-Learning,代码行数:10,代码来源:Program.cs


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