/// <summary> /// Вычисление значения функции ошибки для выбранной модели искусственной сети. /// </summary> private static double CalculateNetworkErrorValue(INeuralNetwork neuralNetwork, IEnumerable <Tuple <IList <double>, IList <double> > > validationSet) { var networkErrorValue = 0.0; Parallel.ForEach(validationSet, (Tuple <IList <double>, IList <double> > validationSample) => { var inputVector = validationSample.Item1; var networkOutput = neuralNetwork.Calculate(inputVector); var desiredOutputVector = validationSample.Item2; for (var i = 0; i < desiredOutputVector.Count(); i++) { networkErrorValue += Math.Abs(desiredOutputVector[i] - networkOutput[i]); } }); return(networkErrorValue); }