public static void validateOutputLayerForClassifierEvaluation ( Layer outputLayer , Class < ? extends IEvaluation > classifierEval ) { if ( outputLayer instanceof Yolo2OutputLayer ) { throw new IllegalStateException ( "Classifier evaluation using " + classifierEval . getSimpleName ( ) + " class cannot be applied for object" + " detection evaluation using Yolo2OutputLayer: " + classifierEval . getSimpleName ( ) + " class is for classifier evaluation only." ) ; } //Check that the activation function provides probabilities. This can't catch everything, but should catch a few // of the common mistakes users make if ( outputLayer instanceof BaseLayer ) { BaseLayer bl = ( BaseLayer ) outputLayer ; boolean isOutputLayer = outputLayer instanceof OutputLayer || outputLayer instanceof RnnOutputLayer || outputLayer instanceof CenterLossOutputLayer ; if ( activationExceedsZeroOneRange ( bl . getActivationFn ( ) , ! isOutputLayer ) ) { throw new IllegalStateException ( "Classifier evaluation using " + classifierEval . getSimpleName ( ) + " class cannot be applied to output" + " layers with activation functions that are not probabilities (in range 0 to 1). Output layer type: " + outputLayer . getClass ( ) . getSimpleName ( ) + " has activation function " + bl . getActivationFn ( ) . getClass ( ) . getSimpleName ( ) + ". This check can be disabled using MultiLayerNetwork.getLayerWiseConfigurations().setValidateOutputLayerConfig(false)" + " or ComputationGraph.getConfiguration().setValidateOutputLayerConfig(false)" ) ; } } }
Validates if the output layer configuration is valid for classifier evaluation . This is used to try and catch invalid evaluation - i . e . trying to use classifier evaluation on a regression model . This method won t catch all possible invalid cases but should catch some common problems .