public static void ReadMetadata(string file) { if (!File.Exists(file)) { throw new IOException("File not found"); } string[] lines = File.ReadAllLines(file); for (int i = 0; i < lines.Length; i++) { CIFARClass.AddKnownClasses((byte)i, lines[i]); } }
public CIFARImage(byte[] data) { if (data.Length != 3073) { throw new ArgumentException("Invalid data Length"); } byte cifarClassByte = data.Take(1).FirstOrDefault(); byte[] redData = data.Skip(1).Take(1024).ToArray(); byte[] greenData = data.Skip(1).Skip(1024).Take(1024).ToArray(); byte[] blueData = data.Skip(1).Skip(1024).Skip(1024).Take(1024).ToArray(); redImageData = redData.ToRowMajor(32).Select(b => b.ToArray()).ToArray(); greenImageData = greenData.ToRowMajor(32).Select(b => b.ToArray()).ToArray(); blueImageData = blueData.ToRowMajor(32).Select(b => b.ToArray()).ToArray(); cifarClass = new CIFARClass(cifarClassByte); }