コード例 #1
0
        static double measureForwardSpeed(IFeedForwardNN nn)
        {
            for (int i = 0; i < 100; i++)
            {
                nn.feedForward(GetRandomInputs(INPUT_SIZE));
            }

            var sw = Stopwatch.StartNew();

            const int laps = 10000;

            //const int laps = 1000;
            for (int i = 0; i < laps; i++)
            {
                nn.feedForward(GetRandomInputs(INPUT_SIZE));
            }

            return(sw.ElapsedMilliseconds);
        }
コード例 #2
0
        static double measureBackpropSpeed(IFeedForwardNN nn, ITrainer tr)
        {
            for (int i = 0; i < 20; i++)
            {
                nn.feedForward(GetRandomInputs(INPUT_SIZE));
            }

            var sw = Stopwatch.StartNew();

            const int laps = 3000;

            //const int laps = 1000;
            for (int i = 0; i < laps; i++)
            {
                nn.feedForward(GetRandomInputs(INPUT_SIZE));
                tr.backpropagate(GetRandomInputs(OUTPUT_SIZE), LEARNING_RATE);
            }

            return(sw.ElapsedMilliseconds);
        }