Example #1
0
        public void CanBackProp()
        {
            CNNet net = new CNNet();

            string toFile     = pathToData + @"somaset\TrainData\1\im0002.jpg";
            var    pic        = JpegToData(toFile).picture;
            var    testVector = PrepareData(pic, 128);
            var    ideal      = new double[] { 0.8 };

            var actual = net.GetResult(testVector);

            Console.WriteLine($"Loss = {net.LossFunction(ideal)}");

            net.BackPropagation(ideal);

            actual = net.GetResult(testVector);
            Console.WriteLine($"Loss = {net.LossFunction(ideal)}");
        }
Example #2
0
        public void CanSaveAndLoadCorrectly()
        {
            string toFile = pathToData + @"somaset\TrainData\1\im0002.jpg";

            CNNet network    = new CNNet();
            var   pic        = JpegToData(toFile).picture;
            var   testVector = PrepareData(pic, 128);
            var   expected   = network.GetResult(testVector);

            File.WriteAllText(pathToData + @"somaset\CanSaveAndLoadCorrectly.json", network.Save());

            CNNet newnet = new CNNet(File.ReadAllText(pathToData + @"somaset\CanSaveAndLoadCorrectly.json"));
            var   actual = newnet.GetResult(testVector);

            Assert.That.AreEqual(expected, actual);
        }