tensorflow/models

View on GitHub
research/slim/nets/resnet_v1.py

Summary

Maintainability
F
1 wk
Test Coverage

File resnet_v1.py has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Minor
Found in research/slim/nets/resnet_v1.py - About 4 hrs to fix

    Function resnet_v1_101 has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def resnet_v1_101(inputs,
    Severity: Major
    Found in research/slim/nets/resnet_v1.py - About 1 hr to fix

      Function resnet_v1 has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def resnet_v1(inputs,
      Severity: Major
      Found in research/slim/nets/resnet_v1.py - About 1 hr to fix

        Function resnet_v1_200 has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def resnet_v1_200(inputs,
        Severity: Major
        Found in research/slim/nets/resnet_v1.py - About 1 hr to fix

          Function resnet_v1_50 has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def resnet_v1_50(inputs,
          Severity: Major
          Found in research/slim/nets/resnet_v1.py - About 1 hr to fix

            Function resnet_v1_152 has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def resnet_v1_152(inputs,
            Severity: Major
            Found in research/slim/nets/resnet_v1.py - About 1 hr to fix

              Function resnet_v1 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              def resnet_v1(inputs,
                            blocks,
                            num_classes=None,
                            is_training=True,
                            global_pool=True,
              Severity: Minor
              Found in research/slim/nets/resnet_v1.py - About 1 hr to fix

              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

              Function bottleneck has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def bottleneck(inputs,
              Severity: Major
              Found in research/slim/nets/resnet_v1.py - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                          if spatial_squeeze:
                            net = tf.squeeze(net, [1, 2], name='SpatialSqueeze')
                            end_points[sc.name + '/spatial_squeeze'] = net
                          end_points['predictions'] = slim.softmax(net, scope='predictions')
                Severity: Major
                Found in research/slim/nets/resnet_v1.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if output_stride is not None:
                              if output_stride % 4 != 0:
                                raise ValueError('The output_stride needs to be a multiple of 4.')
                              output_stride /= 4
                            net = resnet_utils.conv2d_same(net, 64, 7, stride=2, scope='conv1')
                  Severity: Major
                  Found in research/slim/nets/resnet_v1.py - About 45 mins to fix

                    Function bottleneck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def bottleneck(inputs,
                                   depth,
                                   depth_bottleneck,
                                   stride,
                                   rate=1,
                    Severity: Minor
                    Found in research/slim/nets/resnet_v1.py - About 25 mins to fix

                    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

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

                    def resnet_v1_152(inputs,
                                      num_classes=None,
                                      is_training=True,
                                      global_pool=True,
                                      output_stride=None,
                    Severity: Major
                    Found in research/slim/nets/resnet_v1.py and 3 other locations - About 1 day to fix
                    research/slim/nets/resnet_v1.py on lines 284..307
                    research/slim/nets/resnet_v1.py on lines 315..338
                    research/slim/nets/resnet_v1.py on lines 377..400

                    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 170.

                    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

                    def resnet_v1_200(inputs,
                                      num_classes=None,
                                      is_training=True,
                                      global_pool=True,
                                      output_stride=None,
                    Severity: Major
                    Found in research/slim/nets/resnet_v1.py and 3 other locations - About 1 day to fix
                    research/slim/nets/resnet_v1.py on lines 284..307
                    research/slim/nets/resnet_v1.py on lines 315..338
                    research/slim/nets/resnet_v1.py on lines 346..369

                    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 170.

                    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

                    def resnet_v1_101(inputs,
                                      num_classes=None,
                                      is_training=True,
                                      global_pool=True,
                                      output_stride=None,
                    Severity: Major
                    Found in research/slim/nets/resnet_v1.py and 3 other locations - About 1 day to fix
                    research/slim/nets/resnet_v1.py on lines 284..307
                    research/slim/nets/resnet_v1.py on lines 346..369
                    research/slim/nets/resnet_v1.py on lines 377..400

                    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 170.

                    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

                    def resnet_v1_50(inputs,
                                     num_classes=None,
                                     is_training=True,
                                     global_pool=True,
                                     output_stride=None,
                    Severity: Major
                    Found in research/slim/nets/resnet_v1.py and 3 other locations - About 1 day to fix
                    research/slim/nets/resnet_v1.py on lines 315..338
                    research/slim/nets/resnet_v1.py on lines 346..369
                    research/slim/nets/resnet_v1.py on lines 377..400

                    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 170.

                    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 num_classes:
                              net = slim.conv2d(net, num_classes, [1, 1], activation_fn=None,
                                                normalizer_fn=None, scope='logits')
                              end_points[sc.name + '/logits'] = net
                              if spatial_squeeze:
                    Severity: Major
                    Found in research/slim/nets/resnet_v1.py and 1 other location - About 7 hrs to fix
                    research/slim/nets/resnet_v2.py on lines 217..224

                    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 112.

                    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

                    def resnet_v1_block(scope, base_depth, num_units, stride):
                      """Helper function for creating a resnet_v1 bottleneck block.
                    
                      Args:
                        scope: The scope of the block.
                    Severity: Major
                    Found in research/slim/nets/resnet_v1.py and 1 other location - About 3 hrs to fix
                    research/slim/nets/resnet_v2.py on lines 229..249

                    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 73.

                    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 global_pool:
                              # Global average pooling.
                              net = tf.reduce_mean(
                                  input_tensor=net, axis=[1, 2], name='pool5', keepdims=True)
                              end_points['global_pool'] = net
                    Severity: Major
                    Found in research/slim/nets/resnet_v1.py and 1 other location - About 1 hr to fix
                    research/slim/nets/resnet_v2.py on lines 212..216

                    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

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

                              if output_stride is not None:
                                if output_stride % 4 != 0:
                                  raise ValueError('The output_stride needs to be a multiple of 4.')
                                output_stride /= 4
                    Severity: Major
                    Found in research/slim/nets/resnet_v1.py and 1 other location - About 1 hr to fix
                    research/slim/nets/resnet_v2.py on lines 192..195

                    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
                    Status