示例#1
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);
        }
        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;
            }
        }
示例#3
0
        public void TestInputIsNormalizedAccordingToTANHFunction()
        {
            var activationFunction = new ActivationTANH();

            double[] input = new[] { -1.3, -0.7, 0.1, 0.3, 1.1, 0.5 };

            normalizeStrategy.NormalizeInputInPlace(activationFunction, input);

            AssertArraysAreEqual(new[] { -1, -0.7, 0.1, 0.3, 1, 0.5 }, input);
        }
示例#4
0
        public void TestOutputIsNomalizedAccordingToTANHFunction()
        {
            var activationFunction = new ActivationTANH();

            double[] output = new double[] { 1, 0, 1, 0 };

            normalizeStrategy.NormalizeOutputInPlace(activationFunction, output);

            AssertArraysAreEqual(new double[] { 1, -1, 1, -1 }, output);
        }
示例#5
0
        public void createNetwork()
        {
            ActivationFunction threshold = new ActivationTANH();

            this.network = new FeedforwardNetwork();
            this.network.AddLayer(new FeedforwardLayer(threshold, INPUT_SIZE));
            this.network.AddLayer(new FeedforwardLayer(threshold,
                                                       SineWave.NEURONS_HIDDEN_1));
            if (SineWave.NEURONS_HIDDEN_2 > 0)
            {
                this.network.AddLayer(new FeedforwardLayer(threshold,
                                                           SineWave.NEURONS_HIDDEN_2));
            }
            this.network.AddLayer(new FeedforwardLayer(threshold, OUTPUT_SIZE));

            this.network.Reset();
        }
        public void createNetwork()
        {
            ActivationFunction threshold = new ActivationTANH();

            this.network = new FeedforwardNetwork();
            this.network.AddLayer(new FeedforwardLayer(threshold,
                                                       PredictSP500.INPUT_SIZE * 2));
            this.network.AddLayer(new FeedforwardLayer(threshold,
                                                       PredictSP500.NEURONS_HIDDEN_1));
            if (PredictSP500.NEURONS_HIDDEN_2 > 0)
            {
                this.network.AddLayer(new FeedforwardLayer(threshold,
                                                           PredictSP500.NEURONS_HIDDEN_2));
            }
            this.network.AddLayer(new FeedforwardLayer(threshold,
                                                       PredictSP500.OUTPUT_SIZE));
            this.network.Reset();
        }
示例#7
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();
    }
示例#8
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));
                }
            }