private static void GetClassifySampleInputData(ref IEnumerable<BatchInputWrapper> trainData, ref IEnumerable<BatchInputWrapper> cvData)
        {
            List<BatchInputWrapper> trainDataList = new List<BatchInputWrapper>();
            List<BatchInputWrapper> cvDataList = new List<BatchInputWrapper>();

            BatchInputWrapper currentBatch = new BatchInputWrapper(5, 1);
            currentBatch.AddInputAndTrueLabelData(new float[] { 1, 0, 1, 0, 1 }, new float[] { 1 });
            //currentBatch.AddInputAndTrueLabelData(new float[] { 1, 2, 3, 2, 1 }, new float[] { 0 });
            currentBatch.SealBatch();
            trainDataList.Add(currentBatch);
            //currentBatch = new BatchInputWrapper(5, 1);
            //currentBatch.AddInputAndTrueLabelData(new float[] { 1, 2, 0, 2, 1 }, new float[] { 0 });
            //currentBatch.AddInputAndTrueLabelData(new float[] { 1, 0, 3, 0, 1 }, new float[] { 1 });
            //currentBatch.SealBatch();
            //trainDataList.Add(currentBatch);
            trainData = trainDataList.AsEnumerable();

            currentBatch = new BatchInputWrapper(5, 1);
            currentBatch.AddInputAndTrueLabelData(new float[] { 1, 0, 1, 1, 1 }, new float[] { 0 });
            currentBatch.SealBatch();
            cvDataList.Add(currentBatch);
            cvData = cvDataList.AsEnumerable();
        }
        private static void GetClassifySampleInputData(ref IEnumerable <BatchInputWrapper> trainData, ref IEnumerable <BatchInputWrapper> cvData)
        {
            List <BatchInputWrapper> trainDataList = new List <BatchInputWrapper>();
            List <BatchInputWrapper> cvDataList    = new List <BatchInputWrapper>();

            BatchInputWrapper currentBatch = new BatchInputWrapper(5, 1);

            currentBatch.AddInputAndTrueLabelData(new float[] { 1, 0, 1, 0, 1 }, new float[] { 1 });
            //currentBatch.AddInputAndTrueLabelData(new float[] { 1, 2, 3, 2, 1 }, new float[] { 0 });
            currentBatch.SealBatch();
            trainDataList.Add(currentBatch);
            //currentBatch = new BatchInputWrapper(5, 1);
            //currentBatch.AddInputAndTrueLabelData(new float[] { 1, 2, 0, 2, 1 }, new float[] { 0 });
            //currentBatch.AddInputAndTrueLabelData(new float[] { 1, 0, 3, 0, 1 }, new float[] { 1 });
            //currentBatch.SealBatch();
            //trainDataList.Add(currentBatch);
            trainData = trainDataList.AsEnumerable();

            currentBatch = new BatchInputWrapper(5, 1);
            currentBatch.AddInputAndTrueLabelData(new float[] { 1, 0, 1, 1, 1 }, new float[] { 0 });
            currentBatch.SealBatch();
            cvDataList.Add(currentBatch);
            cvData = cvDataList.AsEnumerable();
        }
        private static void GetMNISTInputData(ref IEnumerable <BatchInputWrapper> trainData, ref IEnumerable <BatchInputWrapper> cvData)
        {
            const string filename = @"D:\vinods\Data\MNIST\train.csv";
            // label, pixels
            List <Tuple <float[], float[]> > inputData = new List <Tuple <float[], float[]> >();

            using (StreamReader sr = new StreamReader(filename))
            {
                sr.ReadLine();
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    var          values = line.Split(',');
                    List <float> label  = new List <float>();
                    List <float> pixels = new List <float>();
                    for (int i = 0; i < values.Count(); i++)
                    {
                        if (i == 0)
                        {
                            var tmp = Enumerable.Repeat <float>(0, 10);
                            label.AddRange(tmp);
                            label[int.Parse(values.ElementAt(i))] = 1;
                        }
                        else
                        {
                            pixels.Add(float.Parse(values.ElementAt(i)) / (float)255);
                        }
                    }
                    inputData.Add(Tuple.Create <float[], float[]>(label.ToArray(), pixels.ToArray()));
                }
            }

            Random rnd = new Random();

            for (int i = inputData.Count - 1; i >= 0; i--)
            {
                int swapIndex = rnd.Next(i + 1);
                var tmp       = inputData.ElementAt(i);
                inputData[i]         = inputData.ElementAt(swapIndex);
                inputData[swapIndex] = tmp;
            }

            int cutIndex = (int)(inputData.Count * 0.8);
            int inputDimension = 784, labelDimension = 10;
            // Creating train batches
            BatchInputWrapper        currentBatch = new BatchInputWrapper(inputDimension, labelDimension);
            List <BatchInputWrapper> trainDataList = new List <BatchInputWrapper>();

            foreach (var item in inputData.GetRange(0, cutIndex))
            {
                if (!currentBatch.IsFull)
                {
                    currentBatch.AddInputAndTrueLabelData(item.Item2, item.Item1);
                }
                else
                {
                    currentBatch.SealBatch();
                    trainDataList.Add(currentBatch);
                    currentBatch = new BatchInputWrapper(inputDimension, labelDimension);
                    currentBatch.AddInputAndTrueLabelData(item.Item2, item.Item1);
                }
            }
            currentBatch.SealBatch();
            trainDataList.Add(currentBatch);
            trainData = trainDataList.AsEnumerable();

            // Creating test batches
            currentBatch = new BatchInputWrapper(inputDimension, labelDimension);
            List <BatchInputWrapper> testDataList = new List <BatchInputWrapper>();

            foreach (var item in inputData.GetRange(cutIndex, inputData.Count - cutIndex))
            {
                if (!currentBatch.IsFull)
                {
                    currentBatch.AddInputAndTrueLabelData(item.Item2, item.Item1);
                }
                else
                {
                    currentBatch.SealBatch();
                    testDataList.Add(currentBatch);
                    currentBatch = new BatchInputWrapper(inputDimension, labelDimension);
                    currentBatch.AddInputAndTrueLabelData(item.Item2, item.Item1);
                }
            }
            currentBatch.SealBatch();
            testDataList.Add(currentBatch);
            cvData = testDataList.AsEnumerable();
        }
        private static void GetMNISTInputData(ref IEnumerable<BatchInputWrapper> trainData, ref IEnumerable<BatchInputWrapper> cvData)
        {
            const string filename = @"D:\vinods\Data\MNIST\train.csv";
            // label, pixels
            List<Tuple<float[], float[]>> inputData = new List<Tuple<float[], float[]>>();

            using (StreamReader sr = new StreamReader(filename))
            {
                sr.ReadLine();
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    var values = line.Split(',');
                    List<float> label = new List<float>();
                    List<float> pixels = new List<float>();
                    for (int i = 0; i < values.Count(); i++)
                    {
                        if (i == 0)
                        {
                            var tmp = Enumerable.Repeat<float>(0, 10);
                            label.AddRange(tmp);
                            label[int.Parse(values.ElementAt(i))] = 1;
                        }
                        else
                        {
                            pixels.Add(float.Parse(values.ElementAt(i)) / (float)255);
                        }
                    }
                    inputData.Add(Tuple.Create<float[], float[]>(label.ToArray(), pixels.ToArray()));
                }
            }

            Random rnd = new Random();
            for (int i = inputData.Count - 1; i >= 0; i--)
            {
                int swapIndex = rnd.Next(i + 1);
                var tmp = inputData.ElementAt(i);
                inputData[i] = inputData.ElementAt(swapIndex);
                inputData[swapIndex] = tmp;
            }

            int cutIndex = (int)(inputData.Count * 0.8);
            int inputDimension = 784, labelDimension = 10;
            // Creating train batches
            BatchInputWrapper currentBatch = new BatchInputWrapper(inputDimension, labelDimension);
            List<BatchInputWrapper> trainDataList = new List<BatchInputWrapper>();
            foreach (var item in inputData.GetRange(0, cutIndex))
            {
                if (!currentBatch.IsFull)
                {
                    currentBatch.AddInputAndTrueLabelData(item.Item2, item.Item1);
                }
                else
                {
                    currentBatch.SealBatch();
                    trainDataList.Add(currentBatch);
                    currentBatch = new BatchInputWrapper(inputDimension, labelDimension);
                    currentBatch.AddInputAndTrueLabelData(item.Item2, item.Item1);
                }
            }
            currentBatch.SealBatch();
            trainDataList.Add(currentBatch);
            trainData = trainDataList.AsEnumerable();

            // Creating test batches
            currentBatch = new BatchInputWrapper(inputDimension, labelDimension);
            List<BatchInputWrapper> testDataList = new List<BatchInputWrapper>();
            foreach (var item in inputData.GetRange(cutIndex, inputData.Count - cutIndex))
            {
                if (!currentBatch.IsFull)
                {
                    currentBatch.AddInputAndTrueLabelData(item.Item2, item.Item1);
                }
                else
                {
                    currentBatch.SealBatch();
                    testDataList.Add(currentBatch);
                    currentBatch = new BatchInputWrapper(inputDimension, labelDimension);
                    currentBatch.AddInputAndTrueLabelData(item.Item2, item.Item1);
                }
            }
            currentBatch.SealBatch();
            testDataList.Add(currentBatch);
            cvData = testDataList.AsEnumerable();
        }