deeplearning4j/deeplearning4j

View on GitHub
deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/ComputationGraphConfiguration.java

Summary

Maintainability
F
1 wk
Test Coverage

File ComputationGraphConfiguration.java has 715 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Method fromJson has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

        public static ComputationGraphConfiguration fromJson(String json) {
            //As per MultiLayerConfiguration.fromJson()
            ObjectMapper mapper = NeuralNetConfiguration.mapper();
            ComputationGraphConfiguration conf;
            try {

    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 validate has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        public void validate(boolean allowDisconnected, boolean allowNoOutput){
    
            if (networkInputs == null || networkInputs.isEmpty()) {
                throw new IllegalStateException( "Invalid configuration: network has no inputs. " +
                        "Use .addInputs(String...) to label (and give an ordering to) the network inputs");

    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 build has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

            public ComputationGraphConfiguration build() {
    
                ComputationGraphConfiguration conf = buildConfig();
                conf.validate(allowDisconnected, allowNoOutput); //throws exception for invalid configuration
    
    

    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

    GraphBuilder has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

        @Data
        public static class GraphBuilder {
            private static final int DEFAULT_TBPTT_LENGTH = 20;
    
            protected Map<String, GraphVertex> vertices = new LinkedHashMap<>();

      Method getLayerActivationTypes has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public Map<String,InputType> getLayerActivationTypes(boolean addPreprocIfNecessary,boolean overrideInputs, InputType... inputTypes) {
      
              if (inputTypes == null || inputTypes.length != networkInputs.size()) {
                  throw new IllegalArgumentException(
                          "Invalid number of InputTypes: cannot add preprocessors if number of InputType "

      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 removeVertex has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

              public GraphBuilder removeVertex(String vertexName, boolean removeConnections) {
                  vertices.remove(vertexName);
                  vertexInputs.remove(vertexName);
                  if (networkInputs.contains(vertexName)) {
                      networkInputs.remove(vertexName);

      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 fromJson has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static ComputationGraphConfiguration fromJson(String json) {
              //As per MultiLayerConfiguration.fromJson()
              ObjectMapper mapper = NeuralNetConfiguration.mapper();
              ComputationGraphConfiguration conf;
              try {

        Method topologicalOrdering has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            private List<String> topologicalOrdering() {
                //First step: build network in reverse order (i.e., define map of a -> list(b) instead of list(a) -> b)
                Map<String, List<String>> verticesOutputTo = verticesOutputTo();
                LinkedList<String> noIncomingEdges = new LinkedList<>(networkInputs); //Set of all nodes with no incoming edges
                List<String> topologicalOrdering = new ArrayList<>();

        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 validate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public void validate(boolean allowDisconnected, boolean allowNoOutput){
        
                if (networkInputs == null || networkInputs.isEmpty()) {
                    throw new IllegalStateException( "Invalid configuration: network has no inputs. " +
                            "Use .addInputs(String...) to label (and give an ordering to) the network inputs");

          Method handleLegacyWeightInitFromJson has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              private static void handleLegacyWeightInitFromJson(String json, Layer layer, ObjectMapper mapper, JsonNode vertices) {
                  if (layer instanceof BaseLayer && ((BaseLayer) layer).getWeightInitFn() == null) {
                      String layerName = layer.getLayerName();
          
                      try {

          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 getLayerActivationTypes has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public Map<String,InputType> getLayerActivationTypes(boolean addPreprocIfNecessary,boolean overrideInputs, InputType... inputTypes) {
          
                  if (inputTypes == null || inputTypes.length != networkInputs.size()) {
                      throw new IllegalArgumentException(
                              "Invalid number of InputTypes: cannot add preprocessors if number of InputType "

            Method getMemoryReport has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                public NetworkMemoryReport getMemoryReport(InputType... inputTypes) {
            
            
                    Map<String, MemoryReport> memoryReportMap = new LinkedHashMap<>();
                    List<String> topologicalOrdering = topologicalOrdering();

            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 buildConfig has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    private ComputationGraphConfiguration buildConfig(){
                        //Validate BackpropType setting
                        if((tbpttBackLength != DEFAULT_TBPTT_LENGTH || tbpttFwdLength != DEFAULT_TBPTT_LENGTH) && backpropType != BackpropType.TruncatedBPTT){
                            log.warn("Truncated backpropagation through time lengths have been configured with values " + tbpttFwdLength
                                    + " and " + tbpttBackLength + " but backprop type is set to " + backpropType + ". TBPTT configuration" +

              Method buildConfig has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                      private ComputationGraphConfiguration buildConfig(){
                          //Validate BackpropType setting
                          if((tbpttBackLength != DEFAULT_TBPTT_LENGTH || tbpttFwdLength != DEFAULT_TBPTT_LENGTH) && backpropType != BackpropType.TruncatedBPTT){
                              log.warn("Truncated backpropagation through time lengths have been configured with values " + tbpttFwdLength
                                      + " and " + tbpttBackLength + " but backprop type is set to " + backpropType + ". TBPTT configuration" +

              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 handleLegacyWeightInitFromJson has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static void handleLegacyWeightInitFromJson(String json, Layer layer, ObjectMapper mapper, JsonNode vertices) {
                      if (layer instanceof BaseLayer && ((BaseLayer) layer).getWeightInitFn() == null) {
                          String layerName = layer.getLayerName();
              
                          try {

                Method getMemoryReport has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public NetworkMemoryReport getMemoryReport(InputType... inputTypes) {
                
                
                        Map<String, MemoryReport> memoryReportMap = new LinkedHashMap<>();
                        List<String> topologicalOrdering = topologicalOrdering();

                  Method topologicalOrdering has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private List<String> topologicalOrdering() {
                          //First step: build network in reverse order (i.e., define map of a -> list(b) instead of list(a) -> b)
                          Map<String, List<String>> verticesOutputTo = verticesOutputTo();
                          LinkedList<String> noIncomingEdges = new LinkedList<>(networkInputs); //Set of all nodes with no incoming edges
                          List<String> topologicalOrdering = new ArrayList<>();

                    Method removeVertex has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            public GraphBuilder removeVertex(String vertexName, boolean removeConnections) {
                                vertices.remove(vertexName);
                                vertexInputs.remove(vertexName);
                                if (networkInputs.contains(vertexName)) {
                                    networkInputs.remove(vertexName);

                      Method build has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              public ComputationGraphConfiguration build() {
                      
                                  ComputationGraphConfiguration conf = buildConfig();
                                  conf.validate(allowDisconnected, allowNoOutput); //throws exception for invalid configuration
                      
                      

                        Method verticesOutputTo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private Map<String, List<String>> verticesOutputTo() {
                                Map<String, List<String>> verticesOutputTo = new HashMap<>(); //Key: vertex. Values: vertices that this node is an input for
                                for (Map.Entry<String, GraphVertex> entry : vertices.entrySet()) {
                                    String vertexName = entry.getKey();
                                    List<String> vertexInputNames;

                        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

                        Avoid deeply nested control flow statements.
                        Open

                                                    if(!vertexName.equals(s)){
                                                        newList.add(s);
                                                    }

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  try {
                                      conf = mapper.readValue(json, ComputationGraphConfiguration.class);
                                  } catch (InvalidTypeIdException e){
                                      if(e.getMessage().contains("@class")){
                                          try{
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/MultiLayerConfiguration.java on lines 158..189

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 174.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  for (Map.Entry<String, GraphVertex> entry : vertices.entrySet()) {
                                      String vertexName = entry.getKey();
                                      List<String> vertexInputNames;
                                      vertexInputNames = vertexInputs.get(vertexName);
                          
                          
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/ComputationGraph.java on lines 603..620

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 98.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                      if((tbpttBackLength != DEFAULT_TBPTT_LENGTH || tbpttFwdLength != DEFAULT_TBPTT_LENGTH) && backpropType != BackpropType.TruncatedBPTT){
                                          log.warn("Truncated backpropagation through time lengths have been configured with values " + tbpttFwdLength
                                                  + " and " + tbpttBackLength + " but backprop type is set to " + backpropType + ". TBPTT configuration" +
                                                  " settings will only take effect if backprop type is set to BackpropType.TruncatedBPTT");
                                      }
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/MultiLayerConfiguration.java on lines 649..653

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 66.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                      if (nextEdges != null && !nextEdges.isEmpty()) {
                                          for (String s : nextEdges) {
                                              Set<String> set = inputEdges.get(s);
                                              set.remove(next);
                                              if (set.isEmpty()) {
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/ComputationGraph.java on lines 1298..1306

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 48.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                      } else {
                                          List<String> inputs = vertexInputs.get(s);
                                          if (inputs != null) {
                                              for (String inputVertexName : inputs) {
                                                  inputTypeList.add(vertexOutputs.get(inputVertexName));
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/ComputationGraphConfiguration.java on lines 686..693

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 46.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                      } else {
                                          List<String> inputs = vertexInputs.get(s);
                                          if (inputs != null) {
                                              for (String inputVertexName : inputs) {
                                                  inputTypeList.add(vertexOutputs.get(inputVertexName));
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/ComputationGraphConfiguration.java on lines 557..564

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 46.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 4 locations. Consider refactoring.
                          Open

                              public String toJson() {
                                  //As per MultiLayerConfiguration.toJson()
                                  ObjectMapper mapper = NeuralNetConfiguration.mapper();
                                  synchronized (mapper) {
                                      //JSON mappers are supposed to be thread safe: however, in practice they seem to miss fields occasionally
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/ComputationGraphConfiguration.java on lines 113..122
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/MultiLayerConfiguration.java on lines 106..115
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/MultiLayerConfiguration.java on lines 136..147

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 41.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 4 locations. Consider refactoring.
                          Open

                              public String toYaml() {
                                  ObjectMapper mapper = NeuralNetConfiguration.mapperYaml();
                                  synchronized (mapper) {
                                      try {
                                          return mapper.writeValueAsString(this);
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/ComputationGraphConfiguration.java on lines 142..154
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/MultiLayerConfiguration.java on lines 106..115
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/MultiLayerConfiguration.java on lines 136..147

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 41.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                          if (weightInit != null) {
                                              final IWeightInit wi = WeightInit.valueOf(weightInit.asText()).getWeightInitFunction(dist);
                                              ((BaseLayer) layer).setWeightInitFn(wi);
                                          }
                          deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/MultiLayerConfiguration.java on lines 345..348

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 40.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          There are no issues that match your filters.

                          Category