Пример dl4j canova не работает

Пример Deeplearning4j canova не работает. Я получаю вывод eval.stats как NaN (точность).

import org.slf4j.LoggerFactory;


public class ImageClassifierExample {

    public static void main(String[] args) throws IOException, InterruptedException {


        // Path to the labeled images
        String labeledPath = System.getProperty("user.home")+"/lfw";
         List<String> labels = new ArrayList<>();
        for(File f : new File(labeledPath).listFiles()) {
            labels.add(f.getName());
        }
        // Instantiating a RecordReader pointing to the data path with the specified
        // height and width for each image.
        RecordReader recordReader = new ImageRecordReader(28, 28, true,labels);
        recordReader.initialize(new FileSplit(new File(labeledPath)));

        // Canova to Dl4j
        DataSetIterator iter = new RecordReaderDataSetIterator(recordReader, 784,labels.size());

        // Creating configuration for the neural net.
        MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
                .optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT)
                .constrainGradientToUnitNorm(true)
                .weightInit(WeightInit.DISTRIBUTION)
                .dist(new NormalDistribution(1,1e-5))
                .iterations(100).learningRate(1e-3)
                .nIn(784).nOut(labels.size())
                .visibleUnit(org.deeplearning4j.nn.conf.layers.RBM.VisibleUnit.GAUSSIAN)
                .hiddenUnit(org.deeplearning4j.nn.conf.layers.RBM.HiddenUnit.RECTIFIED)
                .layer(new org.deeplearning4j.nn.conf.layers.RBM())
                .list(4).hiddenLayerSizes(600, 250, 100).override(3, new ConfOverride() {
                    @Override
                    public void overrideLayer(int i, NeuralNetConfiguration.Builder builder) {
                        if (i == 3) {
                            builder.layer(new org.deeplearning4j.nn.conf.layers.OutputLayer());
                            builder.activationFunction("softmax");
                            builder.lossFunction(LossFunctions.LossFunction.MCXENT);

                        }
                    }
                }).build();

        MultiLayerNetwork network = new MultiLayerNetwork(conf);
        network.setListeners(Arrays.<IterationListener>asList(new ScoreIterationListener(10)));

        // Training
        while(iter.hasNext()){
            DataSet next = iter.next();
            network.fit(next);
        }

        // Testing -- We're not doing split test and train
        // Using the same training data as test.
        iter.reset();
        Evaluation eval = new Evaluation();
        while(iter.hasNext()){
            DataSet next = iter.next();
            INDArray predict2 = network.output(next.getFeatureMatrix());
            eval.eval(next.getLabels(), predict2);
        }

        System.out.println(eval.stats());
    }
}

person Jishnu Prathap    schedule 28.01.2016    source источник
comment
Посмотрите этот пример, чтобы узнать, как использовать Canova на CSV: github.com/deeplearning4j/dl4j-0.4-examples/tree/master/src/ И это руководство о том, как применить его к изображениям: deeplearning4j.org/image-data-pipeline.html Наше сообщество активно использует Gitter, если у вас есть дополнительные вопросы: gitter.im/deeplearning4j/deeplearning4j   -  person racknuf    schedule 29.01.2016
comment
@tremstat есть понимание, почему это не работает?   -  person Jishnu Prathap    schedule 29.01.2016


Ответы (1)


Ваша конфигурация NN выглядит так, как будто она основана на очень старой версии dl4j. Наиболее актуальные версии выпуска:

DL4j: 0.4-rc3.8 ND4j: 0.4-rc3.8 Канова: 0.0.0.14

Пожалуйста, попробуйте использовать последние версии

person raver119    schedule 29.01.2016