6using System.Collections.Generic;
10using System.Threading.Tasks;
22 private FileStream _file;
23 private BinaryReader _reader;
24 private bool _disposed =
false;
32 _file = File.Open(strFile, FileMode.Open, FileAccess.Read, FileShare.Read);
33 _reader =
new BinaryReader(_file);
51 protected virtual void Dispose(
bool disposing)
71 GC.SuppressFinalize(
this);
82 get {
return _reader; }
91 UInt32 nVal = _reader.ReadUInt32();
93 return swap_endian(nVal);
103 return _reader.ReadBytes(nCount);
106 private UInt32 swap_endian(UInt32 nVal)
108 nVal = ((nVal << 8) & 0xFF00FF00) | ((nVal >> 8) & 0x00FF00FF);
109 return (nVal << 16) | (nVal >> 16);
The BinaryFile class is used to manage binary files used by the MNIST dataset creator.
BinaryFile(string strFile)
The constructor.
BinaryReader Reader
Returns the binary reader used.
UInt32 ReadUInt32()
Reads in a UINT32 and performs an endian swap.
byte[] ReadBytes(int nCount)
Reads bytes from the file.
void Dispose()
Release all resources.
virtual void Dispose(bool disposing)
Dispose if disposing, or ignore if already disposed.
The MyCaffe.data namespace contains dataset creators used to create common testing datasets such as M...