Class MnistManager


  • public class MnistManager
    extends Object
    • Constructor Detail

      • MnistManager

        public MnistManager​(String imagesFile,
                            String labelsFile,
                            boolean train)
                     throws IOException
        Constructs an instance managing the two given data files. Supports NULL value for one of the arguments in case reading only one of the files (images and labels) is required.
        Parameters:
        imagesFile - Can be NULL. In that case all future operations using that file will fail.
        labelsFile - Can be NULL. In that case all future operations using that file will fail.
        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)
      • close

        public void close()
        Close any resources opened by the manager.