Esempio n. 1
0
 public BackPropagationTrainer(IFeedForwardNetRepository feedForwardNet, IBackPropagationConstants backPropagationConstants, ISquashFunction squashFunction,
                               ITrainingSetRepository trainingSet,
                               IHiddenLayerWeightChangeStrategy hiddenUnitWeightStrategy,
                               IOutputLayerWeightChangeStrategy outputUnitWeightStrategy)
 {
     this.feedForwardNet           = feedForwardNet;
     this.backPropagationConstants = backPropagationConstants;
     this.squashFunction           = squashFunction;
     this.trainingSet = trainingSet;
     this.hiddenUnitWeightStrategy = hiddenUnitWeightStrategy;
     this.outputUnitWeightStrategy = outputUnitWeightStrategy;
 }
Esempio n. 2
0
        public void FeedForwardPass(ISquashFunction squashFunction, ITrainingSetItemRepository trainingSetItem)
        {
            FeedForwardNetLayer currentLayer;
            FeedForwardNetLayer previousLayer;

            for (int currentLayerNo = 0; currentLayerNo < LayerCount(); currentLayerNo++)
            {
                currentLayer = GetLayer(currentLayerNo);
                if (currentLayerNo > 0)
                {
                    previousLayer = GetLayer(currentLayerNo - 1);
                }
                else
                {
                    previousLayer = null;
                }

                SetLayerActivation(ref currentLayer, trainingSetItem, previousLayer, currentLayerNo);

                CalculateNewLayerActivation(ref currentLayer, squashFunction);
            }
            //return ForwardPassError(trainingSetItem, currentLayerNo);
        }
Esempio n. 3
0
        public void CalculateNewLayerActivation(ref FeedForwardNetLayer currentLayer, ISquashFunction squashFunction)
        {
            double weightSum;

            for (int toNo = 0; toNo < currentLayer.GetToUnitCount(); toNo++)
            {
                weightSum = 0.0;
                for (int fromNo = 0; fromNo < currentLayer.GetFromUnitCount(); fromNo++)
                {
                    weightSum += currentLayer.GetFromUnitActivation(fromNo) * currentLayer.GetLayerWeight(fromNo, toNo);
                }
                weightSum += currentLayer.GetLayerBias(toNo);
                currentLayer.SetToUnitActivation(toNo, squashFunction.Squash(weightSum));
            }
        }