Beispiel #1
0
        public void ShowWeights()
        {
            for (int layerCount = 0; layerCount < LayerCount(); layerCount++)
            {
                FeedForwardNetLayer currentLayer = GetLayer(layerCount);

                for (int fromNo = 0; fromNo < currentLayer.GetFromUnitCount(); fromNo++)
                {
                    Console.WriteLine("act layer {0} fromNo {1} = {2} ", layerCount, fromNo, currentLayer.GetFromUnitActivation(fromNo).ToString());
                }

                for (int toNo = 0; toNo < currentLayer.GetToUnitCount(); toNo++)
                {
                    Console.WriteLine("act layer {0} toNo {1} = {2} ", layerCount, toNo, currentLayer.GetToUnitActivation(toNo).ToString());
                }

                for (int toNo = 0; toNo < currentLayer.GetToUnitCount(); toNo++)
                {
                    for (int fromNo = 0; fromNo < currentLayer.GetFromUnitCount(); fromNo++)
                    {
                        Console.WriteLine("layer {0} From {1} To {2} Weight {3}", layerCount, fromNo, toNo, currentLayer.GetLayerWeight(fromNo, toNo).ToString());
                    }
                    Console.WriteLine("layer {0} To {1} bias {2} ", layerCount, toNo, currentLayer.GetLayerBias(toNo).ToString());

                    Console.WriteLine("--------");
                }
            }
        }
Beispiel #2
0
 public void SetLayerActivationHidden(ref FeedForwardNetLayer layer, FeedForwardNetLayer previousLayer)
 {
     for (int fromNo = 0; fromNo < layer.GetFromUnitCount(); fromNo++)
     {
         layer.SetFromUnitActivation(fromNo, previousLayer.GetToUnitActivation(fromNo));
     }
 }
Beispiel #3
0
 public void SetLayerActivationInput(ref FeedForwardNetLayer layer, ITrainingSetItemRepository trainingSetItem)
 {
     for (int fromNo = 0; fromNo < layer.GetFromUnitCount(); fromNo++)
     {
         layer.SetFromUnitActivation(fromNo, trainingSetItem.GetInputNodeValue(fromNo));
     }
 }
Beispiel #4
0
 public void SetLayerActivation(ref FeedForwardNetLayer layer, ITrainingSetItemRepository trainingSetItem, FeedForwardNetLayer previousLayer, int currentLayerNo)
 {
     if (IsFirstLayer(currentLayerNo))
     {
         SetLayerActivationInput(ref layer, trainingSetItem);
     }
     else
     {
         SetLayerActivationHidden(ref layer, previousLayer);
     }
 }
Beispiel #5
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));
            }
        }
Beispiel #6
0
        ErrorMeasure ForwardPassError(ITrainingSetItemRepository trainingSetItem)
        {
            ErrorMeasure errorMeasure;
            double       sumError = 0.0;
            double       localError;
            Boolean      hasLearned = true;

            FeedForwardNetLayer outputLayer = feedForwardNet.GetOutputLayer();

            for (int outputNo = 0; outputNo < outputLayer.GetToUnitCount(); outputNo++)
            {
                localError = Math.Abs(trainingSetItem.GetOutputNodeValue(outputNo) - outputLayer.GetToUnitActivation(outputNo));
                if (localError > backPropagationConstants.OutputTolerance)
                {
                    hasLearned = false;
                }
                sumError += localError;
            }
            errorMeasure = new ErrorMeasure(hasLearned, sumError);
            return(errorMeasure);
        }
Beispiel #7
0
 public void AddLayer(FeedForwardNetLayer layer)
 {
     feedForwardNet.Add(layer);
 }