Source:
<code>public static void main(String[] args) throws Exception { int labelIndex = 4; int numClasses = 3; int batchSizeTraining = 30; DataSet trainingData = readCSVDataset( "/DataExamples/animals/animals_train.csv", batchSizeTraining, labelIndex, numClasses); int batchSizeTest = 44; DataSet testData = readCSVDataset("/DataExamples/animals/animals.csv", batchSizeTest, labelIndex, numClasses); Map<Integer, Map<String, Object>> animals = makeAnimalsForTesting(testData); DataNormalization normalizer = new NormalizerStandardize(); normalizer.fit(trainingData); normalizer.transform(trainingData); normalizer.transform(testData); final int numInputs = 4; int outputNum = 3; int epochs = 1000; long seed = 6; LOGGER.info("Build model...."); MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder() .seed(seed) .activation(Activation.TANH) .weightInit(WeightInit.XAVIER) .updater(new Sgd(0.1)) .l2(1e-4) .list() .layer(new DenseLayer.Builder() .nIn(numInputs) .nOut(3) .build()) .layer(new DenseLayer .Builder() <START> .nIn(3) <END> .nOut(3) .build()) .layer(new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD) .activation(Activation.SOFTMAX) .nIn(3) .nOut(outputNum).build()) .build(); MultiLayerNetwork model = new MultiLayerNetwork(conf); model.init(); model.setListeners(new ScoreIterationListener(100)); for( int i=0; i<epochs; i++ ) { model.fit(trainingData); } Evaluation eval = new Evaluation(3); INDArray output = model.output(testData.getFeatures()); eval.eval(testData.getLabels(), output); LOGGER.info(eval.stats()); setFittedClassifiers(output, animals); logAnimals(animals); }</code><technical_language>remove nIn(...) lines. Dl4j infer this previous layer</technical_language>

Target:
public static void main(String[] args) throws Exception { int labelIndex = 4; int numClasses = 3; int batchSizeTraining = 30; DataSet trainingData = readCSVDataset( "/DataExamples/animals/animals_train.csv", batchSizeTraining, labelIndex, numClasses); int batchSizeTest = 44; DataSet testData = readCSVDataset("/DataExamples/animals/animals.csv", batchSizeTest, labelIndex, numClasses); Map<Integer, Map<String, Object>> animals = makeAnimalsForTesting(testData); DataNormalization normalizer = new NormalizerStandardize(); normalizer.fit(trainingData); normalizer.transform(trainingData); normalizer.transform(testData); final int numInputs = 4; int outputNum = 3; int epochs = 1000; long seed = 6; log.info("Build model...."); MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder() .seed(seed) .activation(Activation.TANH) .weightInit(WeightInit.XAVIER) .updater(new Sgd(0.1)) .l2(1e-4) .list() .layer(new DenseLayer.Builder() .nIn(numInputs) .nOut(3) .build()) .layer(new DenseLayer .Builder() .nOut(3) .build()) .layer(new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD) .activation(Activation.SOFTMAX) .nOut(outputNum).build()) .build(); MultiLayerNetwork model = new MultiLayerNetwork(conf); model.init(); model.setListeners(new ScoreIterationListener(100)); for( int i=0; i<epochs; i++ ) { model.fit(trainingData); } Evaluation eval = new Evaluation(3); INDArray output = model.output(testData.getFeatures()); eval.eval(testData.getLabels(), output); log.info(eval.stats()); setFittedClassifiers(output, animals); logAnimals(animals); }