Encog.Neural.Networks.BasicNetwork.Compute C# (CSharp) Метод

Compute() публичный Метод

Compute the output for a given input to the neural network.
public Compute ( IMLData input ) : IMLData
input IMLData The input to the neural network.
Результат IMLData
        public IMLData Compute(IMLData input)
        {
            try
            {
                IMLData result = new BasicMLData(_structure.Flat.OutputCount);
                _structure.Flat.Compute(input.Data, result.Data);
                return result;
            }
            catch (IndexOutOfRangeException ex)
            {
                throw new NeuralNetworkError(
                    "Index exception: there was likely a mismatch between layer sizes, or the size of the input presented to the network.",
                    ex);
            }
        }

Same methods

BasicNetwork::Compute ( double input, double output ) : void

Usage Example

Пример #1
0
        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();
        }
All Usage Examples Of Encog.Neural.Networks.BasicNetwork::Compute