Accord.Neuro.Learning.DeepNeuralNetworkLearning.RunEpoch C# (CSharp) Method

RunEpoch() public method

Runs a single batch epoch of the learning algorithm.
public RunEpoch ( double input, double output ) : double
input double Array of input vectors.
output double Array of corresponding output vectors.
return double
        public double RunEpoch(double[][] input, double[][] output)
        {
            if (algorithm == null)
                createAlgorithms();

            // Get layer learning algorithm
            var teacher = algorithm;

            // Learn the layer using data
            return teacher.RunEpoch(input, output);
        }

Usage Example

Example #1
0
        public void Train(double[][] i, double[][] o = null, int outputLength = 10, int hiddenLayer = -1)
        {
            if (n == null)
            {
                if (File.Exists(p)) n = DeepBeliefNetwork.Load(p);
                else
                {
                    outputLength = (o == null) ? outputLength : o[0].Length;
                    hiddenLayer = (hiddenLayer == -1) ? (int)Math.Log(i[0].Length, outputLength) : hiddenLayer;
                    List<int> layers = new List<int>();
                    for (int j = 0; j < hiddenLayer; j++) layers.Add(i[0].Length);
                    layers.Add(outputLength);
                    n = new DeepBeliefNetwork(new BernoulliFunction(), i[0].Length, layers.ToArray());
                    new GaussianWeights(n).Randomize();
                }
            }

            dynamic t;
            if (o == null)
            {
                t = new DeepBeliefNetworkLearning(n) { Algorithm = (h, v, j) => new ContrastiveDivergenceLearning(h, v), LayerIndex = n.Machines.Count - 1, };
                while (true) e = t.RunEpoch(t.GetLayerInput(i));
            }
            else
            {
                t = new DeepNeuralNetworkLearning(n) { Algorithm = (ann, j) => new ParallelResilientBackpropagationLearning(ann), LayerIndex = n.Machines.Count - 1, };
                while (true) e = t.RunEpoch(t.GetLayerInput(i), o);
            }
        }
All Usage Examples Of Accord.Neuro.Learning.DeepNeuralNetworkLearning::RunEpoch