public GeneticProgramm(NetworkRandomParams nrp, ConvRandomParams crp, DenseRandomParams drp,
                        int genEpochs, int[] selection, int populationSize, int mutateRate,
                        float accPriority, float paramPriority, int assessmentIndex, int percent)
 {
     _nrp             = nrp;
     _crp             = crp;
     _drp             = drp;
     _genEpochs       = genEpochs;
     _selection       = selection;
     _populationSize  = populationSize;
     _mutateRate      = mutateRate;
     _accPriority     = accPriority;
     _paramPriority   = paramPriority;
     _assessmentIndex = assessmentIndex;
     _percent         = percent;
 }
Example #2
0
 public ConvolutionalChromosome(GeneticProgramm gp, Random random)
 {
     _gp         = gp;
     this.random = random;
     nrp         = gp._nrp;
     crp         = gp._crp;
     drp         = gp._drp;
     convPart    = new ConvStructure(crp, random);
     densePart   = new DenseStructure(nrp, drp, random);
     if (nrp.notRandomSpeed)
     {
         trainConstSpeed = nrp.trainConstSpeedRange[0];
     }
     else
     {
         trainConstSpeed = Convert.ToSingle(random.Next((int)(nrp.trainConstSpeedRange[0] * 1000), (int)(nrp.trainConstSpeedRange[1] * 1000))) / 1000;
     }
     optimizer     = nrp.optimizers[random.Next(nrp.optimizers.Count)];
     loss_function = nrp.loss_functions[random.Next(nrp.loss_functions.Count)];
 }
        public DenseStructure(NetworkRandomParams nrp, DenseRandomParams drp, Random random)
        {
            this.nrp    = nrp;
            this.drp    = drp;
            this.random = random;

            sameActivations = random.Next(100) < 10 ? true : false;
            int absorber = 0;

            if (sameActivations)
            {
                absorber = random.Next(drp.denseActIndexesRange);
            }

            denseLayersNumb = random.Next(1, drp.denseLayersNumbRange);
            denseLayers     = new List <DenseLayer>(denseLayersNumb);

            int powIndex = 0;

            for (int i = 0; i < denseLayers.Capacity; i++)
            {
                int neurons = 0;

                if (i == 0)
                {
                    powIndex = random.Next(Support.GetPow2(nrp.networkOutputNumb), drp.firstDenseNeuronsRange);
                }
                else
                {
                    powIndex += random.Next(0, 2);
                }
                neurons = (int)Math.Pow(2, powIndex);
                denseLayers.Insert(0, new DenseLayer(drp, random, neurons));

                if (sameActivations)
                {
                    denseLayers[0].activationIndex = absorber;
                }
            }
        }
Example #4
0
        public GeneticProgramm CollectConv_NN_Params()
        {
            List <String> convActivations = new List <string>();

            if (reluConvChb.Checked)
            {
                convActivations.Add("relu");
            }
            if (softmaxConvChb.Checked)
            {
                convActivations.Add("softmax");
            }
            if (lReluConvChb.Checked)
            {
                convActivations.Add("Leaky ReLU");
            }
            if (softsignConvChb.Checked)
            {
                convActivations.Add("softsign");
            }
            if (sigmoidConvChb.Checked)
            {
                convActivations.Add("sigmoid");
            }
            if (eluConvChb.Checked)
            {
                convActivations.Add("elu");
            }
            if (seluConvChb.Checked)
            {
                convActivations.Add("selu");
            }
            if (softplusConvChb.Checked)
            {
                convActivations.Add("softplus");
            }
            if (tanhConvChb.Checked)
            {
                convActivations.Add("tang");
            }
            if (PReLUConvChB.Checked)
            {
                convActivations.Add("PReLu");
            }
            if (TReLUConvChB.Checked)
            {
                convActivations.Add("TReLU");
            }

            List <String> denseActivations = new List <string>();

            if (reluDenseChb.Checked)
            {
                denseActivations.Add("relu");
            }
            if (softmaxDenseChb.Checked)
            {
                denseActivations.Add("softmax");
            }
            if (lReluDenseChb.Checked)
            {
                denseActivations.Add("Leaky ReLU");
            }
            if (softsignDenseChb.Checked)
            {
                denseActivations.Add("softsign");
            }
            if (sigmoidDenseChb.Checked)
            {
                denseActivations.Add("sigmoid");
            }
            if (eluDenseChb.Checked)
            {
                denseActivations.Add("elu");
            }
            if (seluDenseChb.Checked)
            {
                denseActivations.Add("selu");
            }
            if (softplusDenseChb.Checked)
            {
                denseActivations.Add("softplus");
            }
            if (tanhDenseChb.Checked)
            {
                denseActivations.Add("tang");
            }
            if (PReLUDenseChB.Checked)
            {
                denseActivations.Add("PReLU");
            }
            if (ThReLUDenseChB.Checked)
            {
                denseActivations.Add("TReLU");
            }

            List <String> optimazers = new List <string>();

            if (SGD_OptChB.Checked)
            {
                optimazers.Add("SGD");
            }

            List <String> lossFunctions = new List <string>();

            if (categorical_crossentropyChB.Checked)
            {
                lossFunctions.Add("categorical_crossentropy");
            }

            List <int> callbacks_indexes = new List <int>();

            if (modelCPChB.Checked)
            {
                callbacks_indexes.Add(0);
            }


            var nrp = new NetworkRandomParams(constSpeedChB.Checked,
                                              new[] { float.Parse(minConstSpeedTB.Text, System.Globalization.CultureInfo.InvariantCulture),
                                                      float.Parse(maxConstSpeedTB.Text, System.Globalization.CultureInfo.InvariantCulture) },
                                              datasetPathTB.Text, modelsPathTB.Text, labelsPathTB.Text, plotsPathTB.Text,
                                              networkNameTB.Text, optimazers, lossFunctions, (int)learningEpochsNUD.Value, (int)batchSizeNUD.Value);

            var crp = new ConvRandomParams((int)ConvLayersNumbNUD.Value,
                                           (int)ConvFiltersNUD.Value,
                                           convActivations.Count,
                                           convActivations,
                                           new[] { (int)slidingWindow1NUD.Value, (int)slidingWindow2NUD.Value },
                                           convDropoutChB.Checked,
                                           (int)convDropoutNUD.Value);
            var drp = new DenseRandomParams((int)DenseLayersNumbNUD.Value,
                                            (int)DenseNeuronsNUD.Value,
                                            nrp.networkOutputNumb, // Support.GetOutputNumb(datasetPath);
                                            denseActivations.Count,
                                            denseActivations,
                                            denseDropoutChB.Checked,
                                            (int)denseDropoutNUD.Value);
            var gp = new GeneticProgramm(nrp, crp, drp, (int)geneticEpochsNUD.Value, new[] { (int)copySelNUD.Value, (int)crossSelNUD.Value, (int)mutateRateNUD.Value },
                                         (int)popolationCountNUD.Value, (int)mutateRateNUD.Value, (float)accPriorityNUD.Value, (float)memPriorityNUD.Value,
                                         EstimatorCB.SelectedIndex, (int)instance.percentNUD.Value);

            return(gp);
        }