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

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.
Результат double
Пример #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);
            }
        }
Пример #2
0
        private void learnLayerSupervised()
        {
            if (!Main.CanClassify) return;
            Dispatcher dispatcher = Dispatcher.CurrentDispatcher;

            new Task(() =>
            {
                DeepNeuralNetworkLearning teacher = new DeepNeuralNetworkLearning(Main.Network)
                {
                    Algorithm = (ann, i) => new ParallelResilientBackpropagationLearning(ann),
                    LayerIndex = Main.Network.Layers.Length - 1,
                };

                double[][] inputs, outputs;
                Main.Database.Training.GetInstances(out inputs, out outputs);

                // Gather learning data for the layer
                double[][] layerData = teacher.GetLayerInput(inputs);

                // Start running the learning procedure
                for (int i = 0; i < Epochs && !shouldStop; i++)
                {
                    double error = teacher.RunEpoch(layerData, outputs);

                    dispatcher.BeginInvoke((Action<int, double>)updateError,
                        DispatcherPriority.ContextIdle, i + 1, error);
                }

                Main.Network.UpdateVisibleWeights();
                IsLearning = false;

            }).Start();
        }