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, setCurrentIndexclose, 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, writeUTFpublic MnistImageFile(java.lang.String name,
java.lang.String mode)
throws java.io.IOException
name - the system-dependent filenamemode - the access modejava.io.IOExceptionjava.io.FileNotFoundExceptionpublic int[][] readImage()
throws java.io.IOException
java.io.IOExceptionpublic byte[][] readImagesUnsafe(int nImages)
throws java.io.IOException
nImages - Number of imagesjava.io.IOExceptionpublic void nextImage()
throws java.io.IOException
java.io.IOExceptionpublic void prevImage()
throws java.io.IOException
java.io.IOExceptionprotected int getMagicNumber()
MnistDbFilegetMagicNumber in class MnistDbFilepublic int getRows()
public int getCols()
public int getEntryLength()
MnistDbFilegetEntryLength in class MnistDbFilepublic int getHeaderSize()
getHeaderSize in class MnistDbFile