Class MnistDbFile
- java.lang.Object
-
- java.io.RandomAccessFile
-
- org.deeplearning4j.datasets.mnist.MnistDbFile
-
- All Implemented Interfaces:
Closeable
,DataInput
,DataOutput
,AutoCloseable
- Direct Known Subclasses:
MnistImageFile
,MnistLabelFile
public abstract class MnistDbFile extends RandomAccessFile
-
-
Constructor Summary
Constructors Constructor Description MnistDbFile(String name, String mode)
Creates new instance and reads the header information.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
getCount()
long
getCurrentIndex()
The current entry index.int
getEntryLength()
Number of bytes for each entry.int
getHeaderSize()
protected abstract int
getMagicNumber()
MNIST DB files start with unique integer number.void
next()
Move to the next entry.void
prev()
Move to the previous entry.void
setCurrentIndex(long curr)
Set the required current entry index.-
Methods inherited from class java.io.RandomAccessFile
close, getChannel, getFD, getFilePointer, length, read, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setLength, skipBytes, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
-
-
-
Constructor Detail
-
MnistDbFile
public MnistDbFile(String name, String mode) throws IOException
Creates new instance and reads the header information.- Parameters:
name
- the system-dependent filenamemode
- the access mode- Throws:
IOException
FileNotFoundException
- See Also:
RandomAccessFile
-
-
Method Detail
-
getMagicNumber
protected abstract int getMagicNumber()
MNIST DB files start with unique integer number.- Returns:
- integer number that should be found in the beginning of the file.
-
getCurrentIndex
public long getCurrentIndex() throws IOException
The current entry index.- Returns:
- long
- Throws:
IOException
-
setCurrentIndex
public void setCurrentIndex(long curr)
Set the required current entry index.- Parameters:
curr
- the entry index
-
getHeaderSize
public int getHeaderSize()
-
getEntryLength
public int getEntryLength()
Number of bytes for each entry. Defaults to 1.- Returns:
- int
-
next
public void next() throws IOException
Move to the next entry.- Throws:
IOException
-
prev
public void prev() throws IOException
Move to the previous entry.- Throws:
IOException
-
getCount
public int getCount()
-
-