コード例 #1
0
        /// <summary>
        ///Evaluates all of the outputs of the neural network.
        /// </summary>
        /// <param name="inputs">Enumerable of all the input values</param>
        /// <returns>dictionary with names of outputs mapping to their values.</returns>
        public Dictionary <string, double> Evaluate(IEnumerable <double> inputs)
        {
            for (int i = 1; i < NumInputs; i++)
            {
                Neurons.TryGetValue(i, out Neuron inputNeuron);
                inputNeuron.Value = inputs.ElementAt(i - 1);
            }
            Dictionary <string, double> outputs = new Dictionary <string, double>();

            for (int i = NumInputs; i < NumInputs + NumOutputs; i++)
            {
                Neurons.TryGetValue(i, out Neuron OutputNeuron);
                outputs.Add(outputNames[i - NumInputs], OutputNeuron.GetValue());
            }
            return(outputs);
        }