Encog.Util.ParamsHolder.GetString C# (CSharp) Method

GetString() public method

Get a param as a string.
public GetString ( String name, bool required, String defaultValue ) : String
name String The name of the string.
required bool True if this value is required.
defaultValue String The default value.
return String
        public String GetString(String name, bool required, String defaultValue)
        {
            if (_paras.ContainsKey(name) )
            {
                return _paras[name];                
            }
            if (required)
            {
                throw new EncogError("Missing property: " + name);
            }
            return defaultValue;
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Create a NEAT population.
        /// </summary>
        /// <param name="architecture">The architecture string to use.</param>
        /// <param name="input">The input count.</param>
        /// <param name="output">The output count.</param>
        /// <returns>The population.</returns>
        public IMLMethod Create(String architecture, int input,
                int output)
        {
            if (input <= 0)
            {
                throw new EncogError("Must have at least one input for NEAT.");
            }

            if (output <= 0)
            {
                throw new EncogError("Must have at least one output for NEAT.");
            }

            IDictionary<String, String> args = ArchitectureParse.ParseParams(architecture);
            ParamsHolder holder = new ParamsHolder(args);

            int populationSize = holder.GetInt(
                    MLMethodFactory.PropertyPopulationSize, false, 1000);

            int cycles = holder.GetInt(
                    MLMethodFactory.PropertyCycles, false, NEATPopulation.DefaultCycles);

            IActivationFunction af = this.factory.Create(
                    holder.GetString(MLMethodFactory.PropertyAF, false, MLActivationFactory.AF_SSIGMOID));

            NEATPopulation pop = new NEATPopulation(input, output, populationSize);
            pop.Reset();
            pop.ActivationCycles = cycles;
            pop.NEATActivationFunction = af;

            return pop;
        }
All Usage Examples Of Encog.Util.ParamsHolder::GetString