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


C# Basic.BasicMLData类代码示例

本文整理汇总了C#中Encog.ML.Data.Basic.BasicMLData的典型用法代码示例。如果您正苦于以下问题:C# BasicMLData类的具体用法?C# BasicMLData怎么用?C# BasicMLData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BasicMLData类属于Encog.ML.Data.Basic命名空间,在下文中一共展示了BasicMLData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: tryMove

        private double tryMove(int[,] board, Move move)
        {
            var input = new BasicMLData (Board.SIZE * Board.SIZE);
            int index = 0;

            for (int x = 0; x < Board.SIZE; x++) {
                for (int y = 0; y < Board.SIZE; y++) {
                    if (board [x, y] == aXon.TicTacToe.Game.TicTacToe.NOUGHTS) {
                        input [index] = -1;
                    } else if (board [x, y] == aXon.TicTacToe.Game.TicTacToe.CROSSES) {
                        input [index] = 1;
                    } else if (board [x, y] == aXon.TicTacToe.Game.TicTacToe.EMPTY) {
                        input [index] = 0;
                    }

                    if ((x == move.x) && (y == move.y)) {
                        input [index] = -1;
                    }

                    index++;
                }
            }
            //var input = new BasicMLData(Board.SIZE*Board.SIZE);

            IMLData output = this.network.Compute (input);
            return output [0];
        }
开发者ID:tmassey,项目名称:mtos,代码行数:27,代码来源:PlayerNeural.cs

示例2: TestSOM

        public void TestSOM()
        {
            // create the training set
            IMLDataSet training = new BasicMLDataSet(
                SOMInput, null);

            // Create the neural network.
            var network = new SOMNetwork(4, 2) {Weights = new Matrix(MatrixArray)};

            var train = new BasicTrainSOM(network, 0.4,
                                          training, new NeighborhoodSingle()) {ForceWinner = true};
            int iteration = 0;

            for (iteration = 0; iteration <= 100; iteration++)
            {
                train.Iteration();
            }

            IMLData data1 = new BasicMLData(
                SOMInput[0]);
            IMLData data2 = new BasicMLData(
                SOMInput[1]);

            int result1 = network.Classify(data1);
            int result2 = network.Classify(data2);

            Assert.IsTrue(result1 != result2);
        }
开发者ID:CreativelyMe,项目名称:encog-dotnet-core,代码行数:28,代码来源:TestCompetitive.cs

示例3: ScorePilot

        public int ScorePilot()
        {
            var sim = new LanderSimulator();
            while (sim.Flying)
            {
                IMLData input = new BasicMLData(3);
                input[0] = _fuelStats.Normalize(sim.Fuel);
                input[1] = _altitudeStats.Normalize(sim.Altitude);
                input[2] = _velocityStats.Normalize(sim.Velocity);
                IMLData output = _network.Compute(input);
                double value = output[0];

                bool thrust;

                if (value > 0)
                {
                    thrust = true;
                    if (_track)
                        Console.WriteLine(@"THRUST");
                }
                else
                    thrust = false;

                sim.Turn(thrust);
                if (_track)
                    Console.WriteLine(sim.Telemetry());
            }
            return (sim.Score);
        }
开发者ID:firestrand,项目名称:encog-dotnet-core,代码行数:29,代码来源:NeuralPilot.cs

示例4: JacobianChainRule

 public JacobianChainRule(BasicNetwork network, IMLDataSet indexableTraining)
 {
     BasicMLData data;
     BasicMLData data2;
     if (0 == 0)
     {
         goto Label_0055;
     }
     Label_0009:
     this._x61830ac74d65acc3 = new BasicMLDataPair(data, data2);
     return;
     Label_0055:
     this._xb12276308f0fa6d9 = indexableTraining;
     if (0 == 0)
     {
     }
     this._x87a7fc6a72741c2e = network;
     this._xabb126b401219ba2 = network.Structure.CalculateSize();
     this._x530ae94d583e0ea1 = (int) this._xb12276308f0fa6d9.Count;
     this._xbdeab667c25bbc32 = EngineArray.AllocateDouble2D(this._x530ae94d583e0ea1, this._xabb126b401219ba2);
     this._xc8a462f994253347 = new double[this._x530ae94d583e0ea1];
     data = new BasicMLData(this._xb12276308f0fa6d9.InputSize);
     data2 = new BasicMLData(this._xb12276308f0fa6d9.IdealSize);
     if (-2147483648 != 0)
     {
         goto Label_0009;
     }
     goto Label_0055;
 }
开发者ID:neismit,项目名称:emds,代码行数:29,代码来源:JacobianChainRule.cs

示例5: LoadCSVTOMemory

        /// <summary>
        /// Load a CSV file into a memory dataset.  
        /// </summary>
        ///
        /// <param name="format">The CSV format to use.</param>
        /// <param name="filename">The filename to load.</param>
        /// <param name="headers">True if there is a header line.</param>
        /// <param name="inputSize">The input size.  Input always comes first in a file.</param>
        /// <param name="idealSize">The ideal size, 0 for unsupervised.</param>
        /// <returns>A NeuralDataSet that holds the contents of the CSV file.</returns>
        public static IMLDataSet LoadCSVTOMemory(CSVFormat format, String filename,
                                                bool headers, int inputSize, int idealSize)
        {
            var result = new BasicMLDataSet();
            var csv = new ReadCSV(filename, headers, format);
            while (csv.Next())
            {
                BasicMLData ideal = null;
                int index = 0;

                var input = new BasicMLData(inputSize);
                for (int i = 0; i < inputSize; i++)
                {
                    double d = csv.GetDouble(index++);
                    input[i] = d;
                }

                if (idealSize > 0)
                {
                    ideal = new BasicMLData(idealSize);
                    for (int i = 0; i < idealSize; i++)
                    {
                        double d = csv.GetDouble(index++);
                        ideal[i] = d;
                    }
                }

                IMLDataPair pair = new BasicMLDataPair(input, ideal);
                result.Add(pair);
            }

            return result;
        }
开发者ID:jongh0,项目名称:MTree,代码行数:43,代码来源:TrainingSetUtil.cs

示例6: LoadCSVToDataSet

        public static IMLDataSet LoadCSVToDataSet(FileInfo fileInfo, int inputCount, int outputCount, bool randomize = true, bool headers = true)
        {
            BasicMLDataSet result = new BasicMLDataSet();
            CultureInfo CSVformat = new CultureInfo("en");

            using (TextFieldParser parser = new TextFieldParser(fileInfo.FullName))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                if (headers)
                    parser.ReadFields();
                while (!parser.EndOfData)
                {
                    //Processing row
                    string[] fields = parser.ReadFields();
                    var input = new BasicMLData(inputCount);
                    for (int i = 0; i < inputCount; i++)
                        input[i] = double.Parse(fields[i], CSVformat);
                    var ideal = new BasicMLData(outputCount);
                    for (int i = 0; i < outputCount; i++)
                        ideal[i] = double.Parse(fields[i + inputCount], CSVformat);
                    result.Add(input, ideal);
                }
            }
            var rand = new Random(DateTime.Now.Millisecond);

            return (randomize ? new BasicMLDataSet(result.OrderBy(r => rand.Next()).ToList()) : new BasicMLDataSet(result));
        }
开发者ID:JGrzybowski,项目名称:NeuralNetworksSmallProject,代码行数:28,代码来源:CSVHelper.cs

示例7: Generate

        /// <summary>
        /// Generate a random training set. 
        /// </summary>
        /// <param name="seed">The seed value to use, the same seed value will always produce
        /// the same results.</param>
        /// <param name="count">How many training items to generate.</param>
        /// <param name="inputCount">How many input numbers.</param>
        /// <param name="idealCount">How many ideal numbers.</param>
        /// <param name="min">The minimum random number.</param>
        /// <param name="max">The maximum random number.</param>
        /// <returns>The random training set.</returns>
        public static BasicMLDataSet Generate(long seed,
            int count, int inputCount,
            int idealCount, double min, double max)
        {
            var rand =
                new LinearCongruentialGenerator(seed);

            var result = new BasicMLDataSet();
            for (int i = 0; i < count; i++)
            {
                var inputData = new BasicMLData(inputCount);

                for (int j = 0; j < inputCount; j++)
                {
                    inputData[j] = rand.Range(min, max);
                }

                var idealData = new BasicMLData(idealCount);

                for (int j = 0; j < idealCount; j++)
                {
                    idealData[j] = rand.Range(min, max);
                }

                var pair = new BasicMLDataPair(inputData,
                                               idealData);
                result.Add(pair);
            }
            return result;
        }
开发者ID:kedrzu,项目名称:encog-dotnet-core,代码行数:41,代码来源:RandomTrainingFactory.cs

示例8: CalculateScore

 /// <inheritdoc />
 public double CalculateScore(IMLMethod genome)
 {
     var prg = (EncogProgram) genome;
     var pop = (PrgPopulation) prg.Population;
     IMLData inputData = new BasicMLData(pop.Context.DefinedVariables.Count);
     prg.Compute(inputData);
     return 0;
 }
开发者ID:benw408701,项目名称:MLHCTransactionPredictor,代码行数:9,代码来源:ZeroEvalScoreFunction.cs

示例9: TestBufferData

        public void TestBufferData()
        {
            File.Delete(Filename);
            var set = new BufferedMLDataSet(Filename);
            set.BeginLoad(2, 1);
            for (int i = 0; i < XOR.XORInput.Length; i++)
            {
                var input = new BasicMLData(XOR.XORInput[i]);
                var ideal = new BasicMLData(XOR.XORIdeal[i]);
                set.Add(input, ideal);
            }
            set.EndLoad();

            XOR.TestXORDataSet(set);
        }
开发者ID:kedrzu,项目名称:encog-dotnet-core,代码行数:15,代码来源:TestBufferedNeuralDataSet.cs

示例10: CreateNoisyXORDataSet

 public static IMLDataSet CreateNoisyXORDataSet(int count)
 {
     var result = new BasicMLDataSet();
     for (int i = 0; i < count; i++)
     {
         for (int j = 0; j < 4; j++)
         {
             var inputData = new BasicMLData(XORInput[j]);
             var idealData = new BasicMLData(XORIdeal[j]);
             var pair = new BasicMLDataPair(inputData, idealData);
             inputData[0] = inputData[0] + RangeRandomizer.Randomize(-0.1, 0.1);
             inputData[1] = inputData[1] + RangeRandomizer.Randomize(-0.1, 0.1);
             result.Add(pair);
         }
     }
     return result;
 }
开发者ID:jongh0,项目名称:MTree,代码行数:17,代码来源:XOR.cs

示例11: Query

        public IntPair Query(int resolution)
        {
            // first, create the input data
            int index = 0;
            BasicMLData inputData = new BasicMLData(resolution * resolution);
            double pixelSize = 2.0 / resolution;
            double orig = -1.0 + (pixelSize / 2.0);

            double yReal = orig;
            for (int y = 0; y < resolution; y++, yReal += pixelSize)
            {
                double xReal = orig;
                for (int x = 0; x < resolution; x++, xReal += pixelSize)
                {
                    inputData.Data[index] = this.test.GetPixel(xReal, yReal);
                    index++;
                }
            }

            // second, query the network
            output = ((NEATNetwork)this.phenotype).Compute(inputData);

            // finally, process the output
            minActivation = Double.PositiveInfinity;
            maxActivation = Double.NegativeInfinity;
            int maxIndex = 0;

            for (int i = 0; i < output.Count; i++)
            {
                double d = output[i];

                if (d > maxActivation)
                {
                    maxActivation = d;
                    maxIndex = i;
                }
                else if (d < minActivation)
                {
                    minActivation = d;
                }
            }

            int yy = maxIndex / resolution;
            int xx = maxIndex - (yy * resolution);
            return new IntPair(xx, yy);
        }
开发者ID:legendvijay,项目名称:aifh,代码行数:46,代码来源:TrialEvaluation.cs

示例12: GenerateSingleDataRange

        public static IMLDataSet GenerateSingleDataRange(EncogFunction task, double start, double stop, double step)
        {
            BasicMLDataSet result = new BasicMLDataSet();
            double current = start;

            while (current <= stop)
            {
                BasicMLData input = new BasicMLData(1);
                input[0] = current;
                BasicMLData ideal = new BasicMLData(1);
                ideal[0] = task(current);
                result.Add(input, ideal);
                current += step;
            }

            return result;
        }
开发者ID:benw408701,项目名称:MLHCTransactionPredictor,代码行数:17,代码来源:GenerationUtil.cs

示例13: ScorePilot

        public int ScorePilot()
        {
            while (sim.Traveling)
            {
                var input = new BasicMLData(2);

                input[0] = sim.DistanceToDestination;
                input[1] = _hStats.Normalize(sim.Heading);

                IMLData output = _network.Compute(input);
                double f = output[0];
                double l = output[1];
                double r = output[2];
                double rev = output[3];

                var dirs = new Dictionary<CommandDirection, double>
                    {
                        {CommandDirection.MoveForward, f},
                        {CommandDirection.TurnLeft, l},
                        {CommandDirection.TurnRight, r},
                        {CommandDirection.MoveInReverse, rev}

                    };
                KeyValuePair<CommandDirection, double> d = dirs.First(v => v.Value == 1.0);

                CommandDirection thrust = d.Key;
                sim.Turn(thrust);

                lock (RobotContol.ConsoleLock)
                {

                    if (_track)
                    {
                        sim.Telemetry();
                        switch (thrust)
                        {
                            default:
                                Thread.Sleep(50);
                                break;
                        }
                    }
                }
            }
            return (sim.Score);
        }
开发者ID:tmassey,项目名称:mtos,代码行数:45,代码来源:NeuralRobot.cs

示例14: LevenbergMarquardtTraining

 public LevenbergMarquardtTraining(BasicNetwork network, IMLDataSet training)
     : base(TrainingImplementationType.Iterative)
 {
     if (2 != 0)
     {
         ValidateNetwork.ValidateMethodToData(network, training);
         if (network.OutputCount != 1)
         {
             throw new TrainingError("Levenberg Marquardt requires an output layer with a single neuron.");
         }
         this.Training = training;
         goto Label_0134;
     }
     Label_00A8:
     this._xdadd8f92d75a3aba = new double[this._xe2982b936ae423cd];
     this._x878c4eb3cef19a5a = new double[this._xe2982b936ae423cd];
     this._x3cb63876dda4b74a = new double[this._xe2982b936ae423cd];
     if (0xff == 0)
     {
         return;
     }
     BasicMLData input = new BasicMLData(this._xb12276308f0fa6d9.InputSize);
     BasicMLData ideal = new BasicMLData(this._xb12276308f0fa6d9.IdealSize);
     this._x61830ac74d65acc3 = new BasicMLDataPair(input, ideal);
     if (-1 != 0)
     {
         return;
     }
     Label_0134:
     this._xb12276308f0fa6d9 = this.Training;
     this._x87a7fc6a72741c2e = network;
     this._x8557b7ee760663f3 = (int) this._xb12276308f0fa6d9.Count;
     this._xe2982b936ae423cd = this._x87a7fc6a72741c2e.Structure.CalculateSize();
     this._x05fb16197e552de6 = new Matrix(this._xe2982b936ae423cd, this._xe2982b936ae423cd);
     this._xc410e3804222557a = this._x05fb16197e552de6.Data;
     this._x6ad505c7ef981b0e = 0.0;
     this._xd7d571ecee49d1e4 = 1.0;
     this._x3271cefb1a159639 = 0.1;
     goto Label_00A8;
 }
开发者ID:neismit,项目名称:emds,代码行数:40,代码来源:LevenbergMarquardtTraining.cs

示例15: SOMColors

        public SOMColors()
        {
            InitializeComponent();

            network = CreateNetwork();
            gaussian = new NeighborhoodRBF(RBFEnum.Gaussian, WIDTH, HEIGHT);
            train = new BasicTrainSOM(network, 0.01, null, gaussian);

            train.ForceWinner = false;

            samples = new List<IMLData>();
            for (int i = 0; i < 15; i++)
            {
                IMLData data = new BasicMLData(3);
                data.Data[0] = RangeRandomizer.Randomize(-1, 1);
                data.Data[1] = RangeRandomizer.Randomize(-1, 1);
                data.Data[2] = RangeRandomizer.Randomize(-1, 1);
                samples.Add(data);
            }

            train.SetAutoDecay(100, 0.8, 0.003, 30, 5);
        }
开发者ID:fxmozart,项目名称:encog-dotnet-more-examples,代码行数:22,代码来源:SOMColors.cs


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