Class MnistManager
- java.lang.Object
-
- org.deeplearning4j.datasets.mnist.MnistManager
-
public class MnistManager extends Object
-
-
Constructor Summary
Constructors Constructor Description MnistManager(String imagesFile, String labelsFile)
MnistManager(String imagesFile, String labelsFile, boolean train)
Constructs an instance managing the two given data files.MnistManager(String imagesFile, String labelsFile, int numExamples)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close any resources opened by the manager.long
getCurrent()
MnistImageFile
getImages()
Get the underlying images file asMnistImageFile
.MnistLabelFile
getLabels()
Get the underlying labels file asMnistLabelFile
.int[][]
readImage()
Reads the current image.byte[]
readImageUnsafe(int i)
int
readLabel()
Reads the current label.int
readLabel(int i)
void
setCurrent(int index)
Set the position to be read.static void
writeImageToPpm(int[][] image, String ppmFileName)
Writes the given image in the given file using the PPM data format.
-
-
-
Constructor Detail
-
MnistManager
public MnistManager(String imagesFile, String labelsFile, boolean train) throws IOException
Constructs an instance managing the two given data files. SupportsNULL
value for one of the arguments in case reading only one of the files (images and labels) is required.- Parameters:
imagesFile
- Can beNULL
. In that case all future operations using that file will fail.labelsFile
- Can beNULL
. In that case all future operations using that file will fail.- Throws:
IOException
-
MnistManager
public MnistManager(String imagesFile, String labelsFile, int numExamples) throws IOException
- Throws:
IOException
-
MnistManager
public MnistManager(String imagesFile, String labelsFile) throws IOException
- Throws:
IOException
-
-
Method Detail
-
writeImageToPpm
public static void writeImageToPpm(int[][] image, String ppmFileName) throws IOException
Writes the given image in the given file using the PPM data format.- Parameters:
image
-ppmFileName
-- Throws:
IOException
-
getCurrent
public long getCurrent()
-
readImage
public int[][] readImage() throws IOException
Reads the current image.- Returns:
- matrix
- Throws:
IOException
-
readImageUnsafe
public byte[] readImageUnsafe(int i)
-
setCurrent
public void setCurrent(int index)
Set the position to be read.- Parameters:
index
-
-
readLabel
public int readLabel() throws IOException
Reads the current label.- Returns:
- int
- Throws:
IOException
-
readLabel
public int readLabel(int i)
-
getImages
public MnistImageFile getImages()
Get the underlying images file asMnistImageFile
.- Returns:
MnistImageFile
.
-
getLabels
public MnistLabelFile getLabels()
Get the underlying labels file asMnistLabelFile
.- Returns:
MnistLabelFile
.
-
close
public void close()
Close any resources opened by the manager.
-
-