Пример #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("--------");
                }
            }
        }
Пример #2
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));
            }
        }
Пример #3
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);
        }