Exemple #1
0
        /// <summary>
        /// Add Hidden Layer, starting from index 0
        /// Do not add Output (idxLayer=numberOfLayers) Layers
        ///
        /// Output Layer will be determined automatically based
        /// on where Neural Net is running in classification of Regression mode
        /// </summary>
        /// <param name="idxLayer"></param>
        /// <param name="numberOfUnits"></param>
        /// <param name="activationFunction"></param>
        public void AddHiddenLayer(int idxLayer,
                                   int numberOfUnits,
                                   IActivationFunction activationFunction)
        {
            if (_model.GetNumberOfLayers() == 0)
            {
                throw new InvalidNeuralNetworkLayer();
            }

            //Input layer is already added by now
            if (idxLayer + 1 >= _model.GetNumberOfLayers() - 1) //throw Error
            {
                throw new InvalidNeuralNetworkLayer();
            }


            _model.AddLayer(idxLayer + 1, numberOfUnits, //Hidden Lalyer
                            _weightBaseValue,
                            activationFunction,
                            _maxParallelThreads);
        }
Exemple #2
0
        protected bool VerifyLayers(ModelBackPropagationBase model)
        {
            bool exceptionFlag = false;

            Parallel.For(0, model.GetNumberOfLayers() - 1,
                         new ParallelOptions {
                MaxDegreeOfParallelism = _maxParallelThreads
            },
                         idxLayer =>
            {
                if (model.GetLayer(idxLayer) == null)
                {
                    exceptionFlag = true;
                }
            });
            return(exceptionFlag);
        }
Exemple #3
0
        protected bool VerifyUpstreamLayers(ModelBackPropagationBase model)
        {
            bool exceptionFlag = false;

            Parallel.For(1, model.GetNumberOfLayers(),
                         new ParallelOptions {
                MaxDegreeOfParallelism = _maxParallelThreads
            },
                         idxLayer =>
            {
                if (model.GetLayer(idxLayer).GetNumberOfUpstreamUnits() < 0)       //Check if Upstream Layer is setup, this will set an exception otherwise
                {
                    exceptionFlag = true;
                }
            });
            return(exceptionFlag);
        }