예제 #1
0
파일: Model.cs 프로젝트: AyoubDSK/DNN
        public Model(Layer[] layers, Connection[] connections, CostFunctions cost_function)
        {
            Layers      = layers;
            Connections = connections;
            OLIndex     = layers.Length - 1;

            switch (cost_function)
            {
            case CostFunctions.MeanSquareSrror:

                if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Sigmoid)
                {
                    Delta_OutputLayer = DeltaMeanSquareErrorSigmoid;
                }

                else if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.TanH)
                {
                    Delta_OutputLayer = DeltaMeanSquareErrorTanH;
                }

                break;

            case CostFunctions.MeanAbsoluteError:

                if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Sigmoid)
                {
                    Delta_OutputLayer = DeltaMeanAbsoluteErrorSigmoid;
                }

                else if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.TanH)
                {
                    Delta_OutputLayer = DeltaMeanAbsoluteErrorTanH;
                }

                break;

            case CostFunctions.CrossEntropy:

                if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Sigmoid)
                {
                    Delta_OutputLayer = DeltaCorssEntorpySigmoid;
                }

                else if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.TanH)
                {
                    Delta_OutputLayer = DeltaCorssEntorpyTanH;
                }

                else if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Softmax)
                {
                    Delta_OutputLayer = DeltaCorssEntorpySoftmax;
                }

                break;

            default:
                throw new ArgumentException("Cost function can't be set");
            }
        }
예제 #2
0
        public NeuralNetwork(Layer[] layers, LConnection[] layers_connections, CostFunctions cost_function, double learing_rate)
        {
            Layers       = layers;
            LConnections = layers_connections;
            OLIndex      = layers.Length - 1;

            foreach (var item in LConnections)
            {
                item.LearningRate = learing_rate;
            }

            switch (cost_function)
            {
            case CostFunctions.MeanSquareSrror:

                if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Sigmoid)
                {
                    Delta_OutputLayer = DeltaMeanSquareErrorSigmoid;
                }

                else if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.TanH)
                {
                    Delta_OutputLayer = DeltaMeanSquareErrorTanH;
                }

                break;

            case CostFunctions.MeanAbsoluteError:

                if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Sigmoid)
                {
                    Delta_OutputLayer = DeltaMeanAbsoluteErrorSigmoid;
                }

                else if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.TanH)
                {
                    Delta_OutputLayer = DeltaMeanAbsoluteErrorTanH;
                }

                break;

            case CostFunctions.CrossEntropy:

                if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Sigmoid)
                {
                    Delta_OutputLayer = DeltaCorssEntorpySigmoid;
                }

                else if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.TanH)
                {
                    Delta_OutputLayer = DeltaCorssEntorpyTanH;
                }

                else if (Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Softmax)
                {
                    Delta_OutputLayer = DeltaCorssEntorpySoftmax;
                }

                break;

            default:
                throw new ArgumentException("Cost function can't be set");
            }
        }
예제 #3
0
파일: Model.cs 프로젝트: CaddyDz/DNN
        private int OLIndex;  //Output layer Index of output model

        public Model(NeuralNetwork[] neural_networks, NNConnection[] neural_networks_Connections, CostFunctions cost_function, double learing_rate = 0.1)
        {
            NeuralNetworks = neural_networks;
            NNConnections  = neural_networks_Connections;

            ONNIndex = NeuralNetworks.Length - 1;
            OLIndex  = NeuralNetworks[ONNIndex].OLIndex;

            switch (cost_function)
            {
            case CostFunctions.MeanSquareSrror:

                if (NeuralNetworks[ONNIndex].Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Sigmoid)
                {
                    Delta_OutputLayer = DeltaMeanSquareErrorSigmoid;
                }

                else if (NeuralNetworks[ONNIndex].Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.TanH)
                {
                    Delta_OutputLayer = DeltaMeanSquareErrorTanH;
                }

                break;

            case CostFunctions.MeanAbsoluteError:

                if (NeuralNetworks[ONNIndex].Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Sigmoid)
                {
                    Delta_OutputLayer = DeltaMeanAbsoluteErrorSigmoid;
                }

                else if (NeuralNetworks[ONNIndex].Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.TanH)
                {
                    Delta_OutputLayer = DeltaMeanAbsoluteErrorTanH;
                }

                break;

            case CostFunctions.CrossEntropy:

                if (NeuralNetworks[ONNIndex].Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Sigmoid)
                {
                    Delta_OutputLayer = DeltaCorssEntorpySigmoid;
                }

                else if (NeuralNetworks[ONNIndex].Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.TanH)
                {
                    Delta_OutputLayer = DeltaCorssEntorpyTanH;
                }

                else if (NeuralNetworks[ONNIndex].Layers[OLIndex].GetActivatonFunction() == Layer.ActivationFunction.Softmax)
                {
                    Delta_OutputLayer = DeltaCorssEntorpySoftmax;
                }

                break;

            default:
                throw new ArgumentException("Cost function can't be set");
            }

            foreach (var item in NNConnections)
            {
                item.Model_Connection_LearningRate = learing_rate;
            }
        }