Java Code Examples for org.nd4j.linalg.dataset.api.iterator.DataSetIterator#getLabels()

The following examples show how to use org.nd4j.linalg.dataset.api.iterator.DataSetIterator#getLabels() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiLayerNetwork.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
/**
 * Evaluate the network (for classification) on the provided data set, with top N accuracy in addition to standard accuracy.
 * For 'standard' accuracy evaluation only, use topN = 1
 *
 * @param iterator   Iterator (data) to evaluate on
 * @param labelsList List of labels. May be null.
 * @param topN       N value for top N accuracy evaluation
 * @return Evaluation object, summarizing the results of the evaluation on the provided DataSetIterator
 */
public Evaluation evaluate(DataSetIterator iterator, List<String> labelsList, int topN) {
    if (layers == null || !(getOutputLayer() instanceof IOutputLayer)) {
        throw new IllegalStateException("Cannot evaluate network with no output layer");
    }
    if (labelsList == null) {
        try {
            labelsList = iterator.getLabels();
        } catch (Throwable t){ }    //Ignore, maybe UnsupportedOperationException etc
    }

    Layer outputLayer = getOutputLayer();
    if(getLayerWiseConfigurations().isValidateOutputLayerConfig()){
        OutputLayerUtil.validateOutputLayerForClassifierEvaluation(outputLayer.conf().getLayer(), Evaluation.class);
    }

    Evaluation e = new org.deeplearning4j.eval.Evaluation(labelsList, topN);
    doEvaluation(iterator, e);

    return e;
}