Esempio n. 1
0
        protected override void Test()
        {
            ConvNet lenet1;
            var     fpath = Path.Combine(OutputPath, "cn_e26_p0.06.mld");

            //var fpath = @"F:\Work\git\ML\solution\ML.DigitsDemo\lenet1.mld";

            using (var stream = File.Open(fpath, FileMode.Open))
            {
                lenet1 = ConvNet.Deserialize(stream);
            }
            var alg = new BackpropAlgorithm(lenet1);

            var fout = Path.Combine(SrcPath, "result1.csv");

            using (var file = File.Open(fout, FileMode.Create, FileAccess.Write))
                using (var writer = new StreamWriter(file))
                {
                    writer.WriteLine("ImageId,Label");

                    int num = 1;
                    foreach (var data in m_Test)
                    {
                        var mark = alg.Predict(data);
                        var idx  = GeneralUtils.ArgMax(mark);
                        var cls  = m_Classes[idx];
                        writer.WriteLine("{0},{1}", num++, (int)cls.Value);
                    }

                    writer.Flush();
                }
        }
Esempio n. 2
0
        protected override double CalculateProximity(double[] mark1, double[] mark2, double threshold)
        {
            if (mark1 == null || mark2 == null)
            {
                return((mark1 == mark2) ? 0 : double.PositiveInfinity);
            }

            var len = mark1.Length;

            if (mark1.Length != mark2.Length)
            {
                return(double.PositiveInfinity);
            }

            return(GeneralUtils.ArgMax(mark1) == GeneralUtils.ArgMax(mark2) ? 0 : 1);
        }