Class Cifar10

java.lang.Object
ai.beestream.jitnn.data.Cifar10
All Implemented Interfaces:
Dataset

public final class Cifar10 extends Object implements Dataset
CIFAR-10 from the binary distribution (cifar-10-batches-bin: data_batch_1..5.bin and test_batch.bin, each record a label byte and 3072 pixel bytes in CHW order). Pixels are scaled to [0, 1] and normalised per channel with the usual means (0.4914, 0.4822, 0.4465) and standard deviations (0.2470, 0.2435, 0.2616). No augmentation: batches come in file order.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
    The number of images.
    final float[]
    The images [count, 3, 32, 32], row-major.
    final int[]
    The class of each image.
    static final int
    Values per image: 3 channels of 32 x 32.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    batch(int b, int size, float[] x, int[] y)
    Copies batch b of size samples, in dataset order, into x and y.
    int
    The number of samples.
    static boolean
    Whether dir, or its cifar-10-batches-bin subdirectory, holds the CIFAR-10 binary files.
    static Cifar10
    load(Path dir, boolean train)
    dir is the directory holding cifar-10-batches-bin (or that directory itself).
    void
    sample(int i, float[] x, int xAt, int[] y, int yAt)
    Copies sample i into x at xAt and its label into y at yAt (DataLoader assembles shuffled batches with it).
    int[]
    The shape of one sample, e.g. {1, 28, 28} or {3, 32, 32}.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Dataset

    sampleSize
  • Field Details

    • PIXELS

      public static final int PIXELS
      Values per image: 3 channels of 32 x 32.
      See Also:
    • images

      public final float[] images
      The images [count, 3, 32, 32], row-major.
    • labels

      public final int[] labels
      The class of each image.
    • count

      public final int count
      The number of images.
  • Method Details

    • load

      public static Cifar10 load(Path dir, boolean train) throws IOException
      dir is the directory holding cifar-10-batches-bin (or that directory itself).
      Throws:
      IOException
    • isPresent

      public static boolean isPresent(Path dir)
      Whether dir, or its cifar-10-batches-bin subdirectory, holds the CIFAR-10 binary files.
    • count

      public int count()
      Description copied from interface: Dataset
      The number of samples.
      Specified by:
      count in interface Dataset
    • sampleShape

      public int[] sampleShape()
      Description copied from interface: Dataset
      The shape of one sample, e.g. {1, 28, 28} or {3, 32, 32}.
      Specified by:
      sampleShape in interface Dataset
    • batch

      public void batch(int b, int size, float[] x, int[] y)
      Description copied from interface: Dataset
      Copies batch b of size samples, in dataset order, into x and y.
      Specified by:
      batch in interface Dataset
    • sample

      public void sample(int i, float[] x, int xAt, int[] y, int yAt)
      Description copied from interface: Dataset
      Copies sample i into x at xAt and its label into y at yAt (DataLoader assembles shuffled batches with it). The default copies through Dataset.batch(int, int, float[], int[]) of size 1.
      Specified by:
      sample in interface Dataset