### Question:
Mnist extends ArrayDataset { public static Builder builder() { return new Builder(); } private  Mnist(Builder builder); static Builder builder(); @Override void prepare(Progress progress); static final int IMAGE_WIDTH; static final int IMAGE_HEIGHT; static final int NUM_CLASSES; }### Answer:
@Test public void testMnistLocal() throws IOException, TranslateException { TrainingConfig config = new DefaultTrainingConfig(Loss.softmaxCrossEntropyLoss()); try (Model model = Model.newInstance("model")) { model.setBlock(Blocks.identityBlock()); NDManager manager = model.getNDManager(); Repository repository = Repository.newInstance("test", "src/test/resources/mlrepo"); Mnist mnist = Mnist.builder() .optManager(manager) .optUsage(Dataset.Usage.TEST) .optRepository(repository) .setSampling(32, true) .build(); try (Trainer trainer = model.newTrainer(config)) { for (Batch batch : trainer.iterateDataset(mnist)) { Assert.assertEquals(batch.getData().size(), 1); Assert.assertEquals(batch.getLabels().size(), 1); batch.close(); } } } }
@Test public void testMnistRemote() throws IOException, TranslateException { TrainingConfig config = new DefaultTrainingConfig(Loss.softmaxCrossEntropyLoss()); try (Model model = Model.newInstance("model")) { model.setBlock(Blocks.identityBlock()); NDManager manager = model.getNDManager(); Mnist mnist = Mnist.builder() .optManager(manager) .optUsage(Dataset.Usage.TEST) .setSampling(32, true) .build(); try (Trainer trainer = model.newTrainer(config)) { for (Batch batch : trainer.iterateDataset(mnist)) { Assert.assertEquals(batch.getData().size(), 1); Assert.assertEquals(batch.getLabels().size(), 1); batch.close(); } } } }