Пример #1
0
        public static void SaveToFile(ETopology top, EFunction fun, EConstrictionFactor cons, List <List <Double> > outputSamples, int id)
        {
            List <String> stringList = new List <string>();
            String        s          = "";

            for (int i = 0; i < Parameters.SAMPLE_COUNT; i++)
            {
                s += (i + 1) + "\t";
            }

            stringList.Add(s + "Fitness\tIterations (Average from 30 samples)");

            for (int i = 0; i < Parameters.ITERATION_AMOUNT; i++)
            {
                String temp = "";
                Double sum  = 0d;
                for (int j = 0; j < Parameters.PARTICLE_AMOUNT; j++)
                {
                    sum  += outputSamples[j][i];
                    temp += outputSamples[j][i] + "\t";
                }
                stringList.Add(temp + i + "\t" + sum / Parameters.PARTICLE_AMOUNT);
            }

            System.IO.File.WriteAllLines(@"WriteLines" + top.ToString() + "," + fun.ToString() + "," + cons.ToString() + "," + id + ".txt", stringList.ToArray());
        }
Пример #2
0
        /// <summary>
        /// Defines CNTK Function with certain arguments.
        /// </summary>
        /// <param name="function">CNTK function</param>
        /// <param name="prediction">First parameters of the function.</param>
        /// <param name="target">Second parameters of the function</param>
        /// <returns></returns>
        private Function createFunction(EFunction function, Function prediction, Variable target)
        {
            switch (function)
            {
            case EFunction.BinaryCrossEntropy:
                return(CNTKLib.BinaryCrossEntropy(prediction, target, function.ToString()));

            case EFunction.CrossEntropyWithSoftmax:
                return(CNTKLib.CrossEntropyWithSoftmax(prediction, target, function.ToString()));

            case EFunction.ClassificationError:
                return(CNTKLib.ClassificationError(prediction, target, function.ToString()));

            case EFunction.SquaredError:
                return(CNTKLib.SquaredError(prediction, target, function.ToString()));

            case EFunction.RMSError:
                return(StatMetrics.RMSError(prediction, target, function.ToString()));

            case EFunction.MSError:
                return(StatMetrics.MSError(prediction, target, function.ToString()));

            case EFunction.ClassificationAccuracy:
                return(StatMetrics.ClassificationAccuracy(prediction, target, function.ToString()));

            default:
                throw new Exception($"The '{function}' function is not supported!");
            }
        }