示例#1
0
        public Vector <double>[] GetFeatures()
        {
            var allFeatures = new Vector <double> [NeuronsCount];

            for (var i = 0; i < Weights.RowCount; i++)
            {
                var norm     = Weights.Row(i).L2Norm();
                var features = Weights.Row(i).Divide(norm);

                allFeatures[i] = features;
            }

            return(allFeatures);
        }
示例#2
0
        public Vector <double> ActivationFunctionPrime(Vector <double> output)
        {
            switch (CurrentActivationFunction)
            {
            case Network.ActivationFunction.Sigmoid:
                return(HelperFunctions.SigmoidPrime(output));

            case Network.ActivationFunction.Tanh:
                return(HelperFunctions.TanhPrime(output));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputsCount">Number of inputs to each vector</param>
        /// <param name="outputsCount">Same as neuron count in this layer</param>
        /// <param name="activationFunction"></param>
        /// <param name="initialWeightsRange"></param>
        public HiddenLayer(
            int inputsCount,
            int outputsCount,
            ActivationFunction activationFunction,
            double initialWeightsRange
            )
        {
            CurrentActivationFunction = activationFunction;
            InputsCount         = inputsCount;
            NeuronsCount        = outputsCount;
            InitialWeightsRange = initialWeightsRange;

            Weights = GetNewWeightsMatrix(false);
            Biases  = GetNewBiasesVector(false);
        }
示例#4
0
 /// <summary>
 /// Takes net as input (this layer output before activation function)
 /// </summary>
 /// <param name="output"></param>
 /// <returns></returns>
 public Vector <double> GetActivation(Vector <double> output)
 {
     return(ActivationFunction(output));
 }
示例#5
0
 public Vector <double> GetNet(Vector <double> inputs)
 {
     //(O x I * I x 1) o 0 x 1 = O x 1
     return(Weights * inputs + Biases);
 }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputs">Vector dimensions: I x 1</param>
        /// <returns></returns>
        public override Vector <double> Feedforward(Vector <double> inputs)
        {
            var output = GetNet(inputs);

            return(GetActivation(output));
        }