Ejemplo n.º 1
0
        /// <summary>
        /// Override that randomly assigns activation functions to neuron's from an activation function library
        /// based on each library item's selection probability.
        /// </summary>
        public override NeuronGene CreateNeuronGene(uint innovationId, NodeType neuronType)
        {
            switch (neuronType)
            {
            case NodeType.Bias:
            case NodeType.Input:
            {       // Use the ID of the first function. By convention this will be the a sigmoid function in nEAT and RBF-NEAT
                    // but in actual fact bias and input neurons don't use their activation function.
                int activationFnId = _activationFnLibrary.GetFunctionList()[0].Id;
                return(new NeuronGene(innovationId, neuronType, activationFnId));
            }

            default:
            {
                ActivationFunctionInfo fnInfo = _activationFnLibrary.GetRandomFunction(_rng);
                IActivationFunction    actFn  = fnInfo.ActivationFunction;
                double[] auxArgs = null;
                if (actFn.AcceptsAuxArgs)
                {
                    auxArgs = actFn.GetRandomAuxArgs(_rng, _neatGenomeParamsCurrent.ConnectionWeightRange);
                }

                return(new NeuronGene(innovationId, neuronType, fnInfo.Id, auxArgs));
            }
            }
        }