public void ClassifiesSmallImages() { var network = new PerceptronFactory().BuildPerceptron(100); var aSet = new InputProcessor(@"..\..\trainingsets\dataset1\A"); var bSet = new InputProcessor(@"..\..\trainingsets\dataset1\B"); var trainingSet = new List <KeyValuePair <double, double[]> > { new KeyValuePair <double, double[]>(1.0, aSet.BmpToBinaryArr(@"1.jpg")), new KeyValuePair <double, double[]>(1.0, aSet.BmpToBinaryArr(@"2.jpg")), new KeyValuePair <double, double[]>(1.0, aSet.BmpToBinaryArr(@"3.jpg")), new KeyValuePair <double, double[]>(1.0, aSet.BmpToBinaryArr(@"4.jpg")), new KeyValuePair <double, double[]>(1.0, aSet.BmpToBinaryArr(@"5.jpg")), new KeyValuePair <double, double[]>(0.0, bSet.BmpToBinaryArr(@"1.jpg")), new KeyValuePair <double, double[]>(0.0, bSet.BmpToBinaryArr(@"2.jpg")), new KeyValuePair <double, double[]>(0.0, bSet.BmpToBinaryArr(@"3.jpg")), new KeyValuePair <double, double[]>(0.0, bSet.BmpToBinaryArr(@"4.jpg")), new KeyValuePair <double, double[]>(0.0, bSet.BmpToBinaryArr(@"5.jpg")), }; network.Train(trainingSet); trainingSet.ForEach(kvp => Assert.AreEqual(kvp.Key, network.Classify(kvp.Value))); }
public void CanReadBitmapsIntoArrs() { var aSet = new InputProcessor(@"..\..\trainingsets\dataset1\A"); double[] arr = aSet.BmpToBinaryArr(@"1.jpg"); Assert.AreEqual(100, arr.Length); }
public void CanReadBitmapsIntoArrs() { var aSet = new InputProcessor(@"..\..\trainingsets\dataset1\A"); double[] arr = aSet.BmpToBinaryArr(@"1.jpg"); Assert.AreEqual(100, arr.Length); }
public void GeneralisesSmallImages() { var network = new PerceptronFactory().BuildPerceptron(100); var aSet = new InputProcessor(@"..\..\trainingsets\dataset1\A"); var bSet = new InputProcessor(@"..\..\trainingsets\dataset1\B"); var trainingSet = new List<KeyValuePair<double, double[]>> { new KeyValuePair<double, double[]>( 1.0, aSet.BmpToBinaryArr(@"1.jpg") ), new KeyValuePair<double, double[]>( 1.0, aSet.BmpToBinaryArr(@"2.jpg") ), new KeyValuePair<double, double[]>( 1.0, aSet.BmpToBinaryArr(@"3.jpg") ), new KeyValuePair<double, double[]>( 1.0, aSet.BmpToBinaryArr(@"4.jpg") ), new KeyValuePair<double, double[]>( 1.0, aSet.BmpToBinaryArr(@"5.jpg") ), new KeyValuePair<double, double[]>( 0.0, bSet.BmpToBinaryArr(@"1.jpg") ), new KeyValuePair<double, double[]>( 0.0, bSet.BmpToBinaryArr(@"2.jpg") ), new KeyValuePair<double, double[]>( 0.0, bSet.BmpToBinaryArr(@"3.jpg") ), new KeyValuePair<double, double[]>( 0.0, bSet.BmpToBinaryArr(@"4.jpg") ), new KeyValuePair<double, double[]>( 0.0, bSet.BmpToBinaryArr(@"5.jpg") ), }; network.Train(trainingSet); Assert.AreEqual(1.0, network.Classify(aSet.BmpToBinaryArr(@"7.jpg"))); Assert.AreEqual(0.0, network.Classify(bSet.BmpToBinaryArr(@"7.jpg"))); }