static void Main(string[] args)
        {
            var data = FileReaderMNIST.LoadImagesAndLables(
                "./data/train-labels-idx1-ubyte.gz",
                "./data/train-images-idx3-ubyte.gz");
            var training = data.Take(50000);

            var test = FileReaderMNIST.LoadImagesAndLables(
                "./data/t10k-labels-idx1-ubyte.gz",
                "./data/t10k-images-idx3-ubyte.gz");

            //  var network = new Network(new[] { 784, 30, 10 });
            //  network.GradientDescent(training, 30, 10, 3.0, test);

            Console.WriteLine("Creating a " + 784 + "-" + 30 + "-" + 10 + " neural network");
            var network = new NeuralNetwork(new[] { 784, 100, 10 });

            var trainingData = ConvertData(training);
            var testData     = ConvertData(test);

            network.GradientDescent(trainingData, 30, 10, 3.0, testData);
        }
    // http://yann.lecun.com/exdb/mnist/
    public static IEnumerable <(double[] image, int label)> GetMNISTHandwrittenNumbers(string labelFileName, string imageFileName)
    {
        var dataDirectory = $"{TrainingDataDir}/{MNISTHandwrittenNumbersDir}";

        EnsureMNISTHandwrittenNumbersDataExists(dataDirectory);

        var trainingDataSet = FileReaderMNIST.LoadImagesAndLables($"{dataDirectory}/{labelFileName}", $"{dataDirectory}/{imageFileName}");

        foreach (var trainingData in trainingDataSet)
        {
            var trainingDataAsDoubleArray = new double[784];
            var trainingDataAsDouble      = trainingData.AsDouble();
            for (var i = 0; i < 28; i++)
            {
                for (var j = 0; j < 28; j++)
                {
                    trainingDataAsDoubleArray[j + (28 * i)] = trainingDataAsDouble[i, j];
                }
            }
            yield return(trainingDataAsDoubleArray, trainingData.Label);
        }
    }
 public MNISTmanager(string LPath, string IPath)
 {
     ClusterImageIndex = 0;
     ClusterLabelIndex = 0;
     data = Shuffle(FileReaderMNIST.LoadImagesAndLables(LPath, IPath).ToList());
 }
Exemple #4
0
        public IEnumerator <TestCase> LoadFiles(string labelsZipFile, string imagesZipFile)
        {
            var imagesAndLabels = FileReaderMNIST.LoadImagesAndLables(labelsZipFile, imagesZipFile);

            return(imagesAndLabels.GetEnumerator());
        }