示例#1
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));
            }
        }
示例#2
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("--------");
                }
            }
        }