### Question:
Cifar10 extends ArrayDataset { public static Builder builder() { return new Builder(); } Cifar10(Builder builder); static Builder builder(); @Override void prepare(Progress progress); static final int IMAGE_WIDTH; static final int IMAGE_HEIGHT; static final float[] NORMALIZE_MEAN; static final float[] NORMALIZE_STD; }### Answer:
@Test public void testCifar10Local() throws IOException, TranslateException { TrainingConfig config = new DefaultTrainingConfig(Loss.softmaxCrossEntropyLoss()); try (Model model = Model.newInstance("model")) { model.setBlock(Blocks.identityBlock()); int batchSize = config.getDevices().length * 32; Repository repository = Repository.newInstance("test", "src/test/resources/mlrepo"); Cifar10 cifar10 = Cifar10.builder() .optManager(model.getNDManager()) .optUsage(Usage.TEST) .optRepository(repository) .setSampling(batchSize, true) .build(); try (Trainer trainer = model.newTrainer(config)) { for (Batch batch : trainer.iterateDataset(cifar10)) { Assert.assertEquals(batch.getData().size(), 1); Assert.assertEquals(batch.getLabels().size(), 1); batch.close(); } } } }
@Test public void testCifar10Remote() throws IOException, TranslateException { TrainingConfig config = new DefaultTrainingConfig(Loss.softmaxCrossEntropyLoss()); try (Model model = Model.newInstance("model")) { model.setBlock(Blocks.identityBlock()); Cifar10 cifar10 = Cifar10.builder() .optManager(model.getNDManager()) .optUsage(Usage.TEST) .setSampling(32, true) .build(); try (Trainer trainer = model.newTrainer(config)) { for (Batch batch : trainer.iterateDataset(cifar10)) { Assert.assertEquals(batch.getData().size(), 1); Assert.assertEquals(batch.getLabels().size(), 1); batch.close(); } } } }