private void CBAktywacje_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            ComboBoxItem typeItem = (ComboBoxItem)CBAktywacje.SelectedItem;
            string       value    = typeItem.Content.ToString();

            switch (value)
            {
            case "Linear":
                ActivationFunction = new ActivationLinear();
                break;

            case "LOG":
                ActivationFunction = new ActivationLOG();
                break;

            case "Sigmoid":
                ActivationFunction = new ActivationSigmoid();
                break;

            case "SIN":
                ActivationFunction = new ActivationSIN();
                break;

            case "TANH":
                ActivationFunction = new ActivationTANH();
                break;
            }
        }
Exemple #2
0
        public IActivationFunction GetActivationFunction()
        {
            IActivationFunction activation;

            switch (ActivationFunction)
            {
            case ActivationFunctionType.Linear:
                activation = new ActivationLinear();
                break;

            case ActivationFunctionType.Sigmoid:
                activation = new ActivationSigmoid();
                break;

            case ActivationFunctionType.TanH:
                activation = new ActivationTANH();
                break;

            case ActivationFunctionType.SoftMax:
                activation = new ActivationSoftMax();
                break;

            case ActivationFunctionType.ReLU:
                activation = new ActivationReLU();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(activation);
        }
        /// <summary>
        /// Setup for training.
        /// </summary>
        private void Init()
        {
            // default values
            ParamActivationMutationRate    = 0.1;
            ParamChanceAddLink             = 0.07;
            ParamChanceAddNode             = 0.04;
            ParamChanceAddRecurrentLink    = 0.05;
            ParamCompatibilityThreshold    = 0.26;
            ParamCrossoverRate             = 0.7;
            ParamMaxActivationPerturbation = 0.1;
            ParamMaxNumberOfSpecies        = 0;
            ParamMaxPermittedNeurons       = 100;
            ParamMaxWeightPerturbation     = 0.5;
            ParamMutationRate                = 0.2;
            ParamNumAddLinkAttempts          = 5;
            ParamNumGensAllowedNoImprovement = 15;
            ParamNumTrysToFindLoopedLink     = 5;
            ParamNumTrysToFindOldLink        = 5;
            ParamProbabilityWeightReplaced   = 0.1;

            NeatActivationFunction   = new ActivationSigmoid();
            OutputActivationFunction = new ActivationLinear();


            //
            NEATGenome genome = (NEATGenome)Population.Genomes[0];

            Population.Innovations =
                new NEATInnovationList(Population, genome.Links,
                                       genome.Neurons);

            splits = Split(null, 0, 1, 0);

            if (CalculateScore.ShouldMinimize)
            {
                bestEverScore = double.MaxValue;
            }
            else
            {
                bestEverScore = double.MinValue;
            }

            ResetAndKill();
            SortAndRecord();
            SpeciateAndCalculateSpawnLevels();
        }
Exemple #4
0
        public static FeedforwardNetwork CreateNetwork()
        {
            ActivationFunction threshold = new ActivationSigmoid();
            FeedforwardNetwork network   = new FeedforwardNetwork();

            network.AddLayer(new FeedforwardLayer(threshold, Config.INPUT_SIZE));
            network.AddLayer(new FeedforwardLayer(threshold,
                                                  Config.NEURONS_HIDDEN_1));
            if (Config.NEURONS_HIDDEN_2 > 0)
            {
                network.AddLayer(new FeedforwardLayer(threshold,
                                                      Config.NEURONS_HIDDEN_2));
            }
            network.AddLayer(new FeedforwardLayer(threshold, Config.OUTPUT_SIZE));
            network.Reset();
            return(network);
        }
Exemple #5
0
    /// <summary>
    /// Creates a feedforward NN
    /// </summary>
    public virtual void createNetwork()
    {
      IActivationFunction threshold;

      if (ACTIVIATION_FUNCTION == 1)
        threshold = new ActivationSigmoid();
      else if (ACTIVIATION_FUNCTION == 2)
        threshold = new ActivationTANH();
      else
        throw new System.Exception("Only 2 activation functions have been impletemented.");

      network = new BasicNetwork();
      network.AddLayer(new BasicLayer(threshold, true, INPUT_NEURONS));
      network.AddLayer(new BasicLayer(threshold, true, HIDDENLAYER1_NEURONS));

      if (HIDDENLAYER2_NEURONS > 0)
      {
        network.AddLayer(new BasicLayer(threshold, true, HIDDENLAYER2_NEURONS));
      }

      network.AddLayer(new BasicLayer(threshold, true, OUTPUT_NEURONS));
      network.Structure.FinalizeStructure();
      network.Reset();
    }
Exemple #6
0
            void AddLayers(List <LayerConfig> gen)
            {
                foreach (var g in gen)
                {
                    IActivationFunction act;
                    if (g.ActivationType == 0)
                    {
                        act = new ActivationBiPolar();
                    }
                    switch (g.ActivationType)
                    {
                    case 0:
                        act = new ActivationBiPolar();
                        break;

                    case 1:
                        act = new ActivationBipolarSteepenedSigmoid();
                        break;

                    case 2:
                        act = new ActivationClippedLinear();
                        break;

                    case 3:
                        act = new ActivationCompetitive();
                        break;

                    case 4:
                        act = new ActivationElliott();
                        break;

                    case 5:
                        act = new ActivationElliottSymmetric();
                        break;

                    case 6:
                        act = new ActivationGaussian();
                        break;

                    case 7:
                        act = new ActivationLinear();
                        break;

                    case 8:
                        act = new ActivationLOG();
                        break;

                    case 9:
                        act = new ActivationRamp();
                        break;

                    case 10:
                        act = new ActivationRamp();
                        break;

                    case 11:
                        act = new ActivationSigmoid();
                        break;

                    case 12:
                        act = new ActivationSIN();
                        break;

                    case 13:
                        act = new ActivationSoftMax();
                        break;

                    case 14:
                        act = new ActivationSteepenedSigmoid();
                        break;

                    case 15:
                        act = new ActivationStep();
                        break;

                    case 16:
                        act = new ActivationTANH();
                        break;

                    default:
                        act = new ActivationSoftMax();
                        break;
                    }
                    network.AddLayer(new BasicLayer(act, g.hasBias, g.neurons));
                }
            }
Exemple #7
0
        private NEATNetwork Create()
        {
            IList <NEATNeuron>  neurons   = new List <NEATNeuron>();
            IActivationFunction afSigmoid = new ActivationSigmoid();
            IActivationFunction afStep    = new ActivationStep();

            // create the neurons
            NEATNeuron input1 = new NEATNeuron(
                NEATNeuronType.Input,
                1,
                0.1,
                0.2,
                0.3);

            NEATNeuron input2 = new NEATNeuron(
                NEATNeuronType.Input,
                2,
                0.1,
                0.2,
                0.3);

            NEATNeuron bias = new NEATNeuron(
                NEATNeuronType.Bias,
                3,
                0.1,
                0.2,
                0.3);

            NEATNeuron hidden1 = new NEATNeuron(
                NEATNeuronType.Hidden,
                4,
                0.1,
                0.2,
                0.3);

            NEATNeuron output = new NEATNeuron(
                NEATNeuronType.Output,
                5,
                0.1,
                0.2,
                0.3);

            // add the neurons
            neurons.Add(input1);
            neurons.Add(input2);
            neurons.Add(hidden1);
            neurons.Add(bias);
            neurons.Add(output);

            // connect everything
            Link(0.01, input1, hidden1, false);
            Link(0.01, input2, hidden1, false);
            Link(0.01, bias, hidden1, false);
            Link(0.01, hidden1, output, false);

            // create the network
            NEATNetwork result = new NEATNetwork(2,
                                                 1,
                                                 neurons,
                                                 afSigmoid,
                                                 afStep,
                                                 3);

            return(result);
        }