TrainEpoch() 공개 메소드

public TrainEpoch ( TrainingData data ) : float
data TrainingData
리턴 float
예제 #1
0
        static void Main(string[] argv)
        {
            const uint max_epochs = 1000;
            uint num_threads = 1;
            TrainingData data;
            NeuralNet net;
            long before;
            float error;

            if (argv.Length == 2)
                num_threads = UInt32.Parse(argv[1]);
            using (data = new TrainingData("..\\..\\..\\datasets\\mushroom.train"))
            using (net = new NeuralNet(NetworkType.LAYER, 3, data.InputCount, 32, data.OutputCount))
            {
                net.ActivationFunctionHidden = ActivationFunction.SIGMOID_SYMMETRIC;
                net.ActivationFunctionOutput = ActivationFunction.SIGMOID;

                before = Environment.TickCount;
                for (int i = 1; i <= max_epochs; i++)
                {
                    error = num_threads > 1 ? net.TrainEpochIrpropmParallel(data, num_threads) : net.TrainEpoch(data);
                    Console.WriteLine("Epochs     {0}. Current error: {1}", i.ToString("00000000"), error.ToString("0.0000000000"));
                }

                Console.WriteLine("ticks {0}", Environment.TickCount - before);
                Console.ReadKey();
            }
        }
예제 #2
0
        private static void TrainOnSteepnessFile(NeuralNet net, string filename,
            uint max_epochs, uint epochs_between_reports,
            float desired_error, float steepness_start,
            float steepness_step, float steepness_end)
        {
            float error;
            using (TrainingData data = new TrainingData())
            {
                data.ReadTrainFromFile(filename);

                if (epochs_between_reports != 0)
                {
                    Console.WriteLine("Max epochs {0}. Desired error: {1}", max_epochs.ToString("00000000"), desired_error.ToString("0.0000000000"));
                }

                net.ActivationSteepnessHidden = steepness_start;
                net.ActivationSteepnessOutput = steepness_start;
                for (int i = 1; i <= max_epochs; i++)
                {
                    error = net.TrainEpoch(data);

                    if(epochs_between_reports != 0 && (i % epochs_between_reports == 0 || i == max_epochs || i == 1 || error < desired_error))
                    {
                        Console.WriteLine("Epochs     {0}. Current error: {1}", i.ToString("00000000"), error.ToString("0.0000000000"));
                    }

                    if(error < desired_error)
                    {
                        steepness_start += steepness_step;
                        if(steepness_start <= steepness_end)
                        {
                            Console.WriteLine("Steepness: {0}", steepness_start);
                            net.ActivationSteepnessHidden = steepness_start;
                            net.ActivationSteepnessOutput = steepness_start;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }