protected virtual void OnBeginSample(int currentIteration, CY_NN_Dataset_Entry e)
 {
     if (BeginSampleEvent != null)
     {
         BeginSampleEvent(this, new CY_Dataset_Entry_Args(currentIteration, e));
     }
 }
        public virtual void Learn(CY_NN_Dataset set, int trainingEpochs)
        {
            isStopping = false;
            Initialize();
            for (int currentIteration = 0; currentIteration < trainingEpochs; currentIteration++)
            {
                int[] randomOrder = GetRandomOrder(set.trainingSamples.Count);
                OnBeginEpoch(currentIteration, set);

                if (jitterEpoch > 0 && currentIteration % jitterEpoch == 0)
                {
                    for (int i = 0; i < connectors.Count; i++)
                    {
                        connectors[i].noise(jitterNoiseLimit);
                    }
                }

                for (int index = 0; index < set.trainingSamples.Count; index++)
                {
                    CY_NN_Dataset_Entry e = set[randomOrder[index]];
                    OnBeginSample(currentIteration, e);
                    LearnSample(set[randomOrder[index]], currentIteration, trainingEpochs);
                    OnEndSample(currentIteration, e);
                    if (isStopping)
                    {
                        isStopping = false; return;
                    }
                }
                OnEndEpoch(currentIteration, set);
                if (isStopping)
                {
                    isStopping = false; return;
                }
            }
        }
        protected override void LearnSample(CY_NN_Dataset_Entry e, int currentIteration, int trainingEpochs)
        {
            int layerCount = layers.Count;

            inputLayer.SetInput(e.inputV);
            for (int i = 0; i < layerCount; i++)
            {
                layers[i].calcFire();
            }
            mse += (outputLayer as CY_NeuronLayer).SetErrors(e.outputV);
            for (int i = layerCount; i > 0;)
            {
                CY_NeuronLayer layer = layers[--i] as CY_NeuronLayer;
                if (layer != null)
                {
                    layer.calcError();
                }
            }
            for (int i = 0; i < layerCount; i++)
            {
                layers[i].Learn(currentIteration, trainingEpochs);
            }
        }
 public CY_Dataset_Entry_Args(int i, CY_NN_Dataset_Entry e)
 {
     this.i = i;
     this.e = e;
 }
 public override void Learn(CY_NN_Dataset_Entry e, int i, int max_i)
 {
     mse = 0d;
     base.Learn(e, i, max_i);
 }
 protected abstract void LearnSample(CY_NN_Dataset_Entry e, int i, int max_i);
 public virtual void Learn(CY_NN_Dataset_Entry e, int i, int max_i)
 {
     OnBeginSample(i, e);
     LearnSample(e, i, max_i);
     OnEndSample(i, e);
 }