deeplearning4j/deeplearning4j

View on GitHub
deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/earlystopping/trainer/BaseEarlyStoppingTrainer.java

Summary

Maintainability
F
4 days
Test Coverage

Method fit has a Cognitive Complexity of 141 (exceeds 5 allowed). Consider refactoring.
Open

    protected EarlyStoppingResult<T> fit(boolean pretrain) {
        esConfig.validate();
        log.info("Starting early stopping training");
        if (esConfig.getScoreCalculator() == null)
            log.warn("No score calculator provided for early stopping. Score will be reported as 0.0 to epoch termination conditions");

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method fit has 193 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected EarlyStoppingResult<T> fit(boolean pretrain) {
        esConfig.validate();
        log.info("Starting early stopping training");
        if (esConfig.getScoreCalculator() == null)
            log.warn("No score calculator provided for early stopping. Score will be reported as 0.0 to epoch termination conditions");

    File BaseEarlyStoppingTrainer.java has 295 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     *  ******************************************************************************
     *  *
     *  *
     *  * This program and the accompanying materials are made available under the

      Method triggerEpochListeners has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          protected void triggerEpochListeners(boolean epochStart, Model model, int epochNum){
              Collection<TrainingListener> listeners;
              if(model instanceof MultiLayerNetwork){
                  MultiLayerNetwork n = ((MultiLayerNetwork) model);
                  listeners = n.getListeners();

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Consider simplifying this complex logical expression.
      Open

                      if ((sc.minimizeScore() && score < bestModelScore) || (!sc.minimizeScore() && score > bestModelScore) || (bestModelEpoch == -1 && invalidScore)) {
                          //Save best model:
                          if (bestModelEpoch == -1) {
                              //First calculated/reported score
                              log.info("Score at epoch {}: {}", epochCount, score);

        There are no issues that match your filters.

        Category
        Status