/// <summary> /// read the data from each image /// </summary> /// <param name="brLabels"></param> /// <param name="brImages"></param> /// <returns></returns> private IList <INetworkInputData> readFileInformation(BinaryReader brLabels, BinaryReader brImages) { var networkData = m_bf.CreateList <INetworkInputData>(); int magic1 = brImages.ReadInt32(); // discard int numImages = brImages.ReadInt32(); int numRows = brImages.ReadInt32(); int numCols = brImages.ReadInt32(); int magic2 = brLabels.ReadInt32(); int numLabels = brLabels.ReadInt32(); if (numImages != numLabels) { throw new IndexOutOfRangeException("The image and label count from the file headers is not equal."); } // each test image for (int di = 0; di < numImages; ++di) { var dataSet = m_bf.CreateNetworkInputData(); dataSet.initDoubleArray(numRows, numCols); for (int i = 0; i < numRows; ++i) { for (int j = 0; j < numCols; ++j) { // to get a number between 0.0 and 1.0 // the biggest byte number is 255, so this is the denominator dataSet.ImageNumbers[i][j] = brImages.ReadByte() / 255.0; } } dataSet.ExpectedResult = brLabels.ReadByte(); networkData.Add(dataSet); } // each image return(networkData); }