public class MnistImageFile extends MnistDbFile
Constructor and Description |
---|
MnistImageFile(java.lang.String name,
java.lang.String mode)
Creates new MNIST database image file ready for reading.
|
Modifier and Type | Method and Description |
---|---|
int |
getCols()
Number of columns per image.
|
int |
getEntryLength()
Number of bytes for each entry.
|
int |
getHeaderSize() |
protected int |
getMagicNumber()
MNIST DB files start with unique integer number.
|
int |
getRows()
Number of rows per image.
|
void |
nextImage()
Move the cursor to the next image.
|
void |
prevImage()
Move the cursor to the previous image.
|
int[][] |
readImage()
Reads the image at the current position.
|
byte[][] |
readImagesUnsafe(int nImages)
Read the specified number of images from the current position, to a byte[nImages][rows*cols]
Note that MNIST data set is stored as unsigned bytes; this method returns signed bytes without conversion
(i.e., same bits, but requires conversion before use)
|
getCount, getCurrentIndex, next, prev, setCurrentIndex
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
public MnistImageFile(java.lang.String name, java.lang.String mode) throws java.io.IOException
name
- the system-dependent filenamemode
- the access modejava.io.IOException
java.io.FileNotFoundException
public int[][] readImage() throws java.io.IOException
java.io.IOException
public byte[][] readImagesUnsafe(int nImages) throws java.io.IOException
nImages
- Number of imagesjava.io.IOException
public void nextImage() throws java.io.IOException
java.io.IOException
public void prevImage() throws java.io.IOException
java.io.IOException
protected int getMagicNumber()
MnistDbFile
getMagicNumber
in class MnistDbFile
public int getRows()
public int getCols()
public int getEntryLength()
MnistDbFile
getEntryLength
in class MnistDbFile
public int getHeaderSize()
getHeaderSize
in class MnistDbFile