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 intgetCount()longgetCurrentIndex()The current entry index.intgetEntryLength()Number of bytes for each entry.intgetHeaderSize()protected abstract intgetMagicNumber()MNIST DB files start with unique integer number.voidnext()Move to the next entry.voidprev()Move to the previous entry.voidsetCurrentIndex(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:
IOExceptionFileNotFoundException- 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 IOExceptionThe 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 IOExceptionMove to the next entry.- Throws:
IOException
-
prev
public void prev() throws IOExceptionMove to the previous entry.- Throws:
IOException
-
getCount
public int getCount()
-
-