コード例 #1
0
        public void TrainingsCycle(double[] echtBild, double[] animie)
        {
            encoder.SetInput(echtBild);
            encoder.OutputBerechnen();
            decoder.SetInput(encoder.GetOutput());
            decoder.OutputBerechnen();

            double[] encoderOutput = encoder.GetOutput();

            encoder.SetInput(decoder.GetOutput());
            encoder.OutputBerechnen();
            encoder.DeltawertBerechen(encoderOutput);

            discriminator.SetInput(decoder.GetOutput());
            discriminator.OutputBerechnen();
            discriminator.DeltawertBerechen(new double[] { 1 });

            decoder.IsertDelta(discriminator.GetFirstLayerDelta());
            decoder.Backpropagation();
            encoder.Backpropagation();

            discriminator.DeltawertBerechen(new double[] { 0 });
            discriminator.Backpropagation();

            discriminator.SetInput(animie);
            discriminator.OutputBerechnen();
            discriminator.DeltawertBerechen(new double[] { 1 });
            discriminator.Backpropagation();
        }
コード例 #2
0
        public void TrainDisciminator(int cycles, string animieFolder)
        {
            string[] files = Directory.GetFiles(animieFolder);

            for (int i = 0; i < cycles; ++i)
            {
                discriminator.SetInput(MatrixMafs.ArrDivNum(GetDoubleArr(File.ReadAllBytes(files[i % files.Length])), 255));
                discriminator.OutputBerechnen();
                discriminator.DeltawertBerechen(new double[] { 1 });
                discriminator.Backpropagation();

                discriminator.SetInput(SimpleNet.GetRandArr(750000, 0, 1));
                discriminator.OutputBerechnen();
                discriminator.DeltawertBerechen(new double[] { 0 });
                discriminator.Backpropagation();

                if (i % 1000 == 0)
                {
                    Console.WriteLine("Trainingscycle nr " + i);
                }
            }
        }