tensorflow/models

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

Summary

Maintainability
F
1 wk
Test Coverage

File inception_resnet_v2.py has 317 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/inception_resnet_v2.py - About 3 hrs to fix

    Function inception_resnet_v2_base has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def inception_resnet_v2_base(inputs,
                                 final_endpoint='Conv2d_7b_1x1',
                                 output_stride=16,
                                 align_feature_maps=False,
                                 scope=None,
    Severity: Minor
    Found in research/slim/nets/inception_resnet_v2.py - About 2 hrs 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 inception_resnet_v2 has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def inception_resnet_v2(inputs, num_classes=1001, is_training=True,
    Severity: Major
    Found in research/slim/nets/inception_resnet_v2.py - About 1 hr to fix

      Function inception_resnet_v2_base has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def inception_resnet_v2_base(inputs,
      Severity: Minor
      Found in research/slim/nets/inception_resnet_v2.py - About 45 mins to fix

        Function inception_resnet_v2_arg_scope has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def inception_resnet_v2_arg_scope(
        Severity: Minor
        Found in research/slim/nets/inception_resnet_v2.py - About 45 mins to fix

          Function block8 has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def block8(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):
          Severity: Minor
          Found in research/slim/nets/inception_resnet_v2.py - About 35 mins to fix

            Function block17 has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def block17(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):
            Severity: Minor
            Found in research/slim/nets/inception_resnet_v2.py - About 35 mins to fix

              Function block35 has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def block35(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):
              Severity: Minor
              Found in research/slim/nets/inception_resnet_v2.py - About 35 mins to fix

                Avoid too many return statements within this function.
                Open

                      if add_and_check_final('MaxPool_5a_3x3', net): return net, end_points
                Severity: Major
                Found in research/slim/nets/inception_resnet_v2.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        if add_and_check_final('Conv2d_4a_3x3', net): return net, end_points
                  Severity: Major
                  Found in research/slim/nets/inception_resnet_v2.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          if add_and_check_final('Mixed_6a', net): return net, end_points
                    Severity: Major
                    Found in research/slim/nets/inception_resnet_v2.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            if add_and_check_final('Mixed_7a', net): return net, end_points
                      Severity: Major
                      Found in research/slim/nets/inception_resnet_v2.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              if add_and_check_final('Conv2d_3b_1x1', net): return net, end_points
                        Severity: Major
                        Found in research/slim/nets/inception_resnet_v2.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                if add_and_check_final('Conv2d_7b_1x1', net): return net, end_points
                          Severity: Major
                          Found in research/slim/nets/inception_resnet_v2.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  if add_and_check_final('PreAuxLogits', net): return net, end_points
                            Severity: Major
                            Found in research/slim/nets/inception_resnet_v2.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    if add_and_check_final('Mixed_5b', net): return net, end_points
                              Severity: Major
                              Found in research/slim/nets/inception_resnet_v2.py - About 30 mins to fix

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

                                def block17(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):
                                  """Builds the 17x17 resnet block."""
                                  with tf.variable_scope(scope, 'Block17', [net], reuse=reuse):
                                    with tf.variable_scope('Branch_0'):
                                      tower_conv = slim.conv2d(net, 192, 1, scope='Conv2d_1x1')
                                Severity: Major
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 2 days to fix
                                research/slim/nets/inception_resnet_v2.py on lines 84..107

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

                                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 block8(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):
                                  """Builds the 8x8 resnet block."""
                                  with tf.variable_scope(scope, 'Block8', [net], reuse=reuse):
                                    with tf.variable_scope('Branch_0'):
                                      tower_conv = slim.conv2d(net, 192, 1, scope='Conv2d_1x1')
                                Severity: Major
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 2 days to fix
                                research/slim/nets/inception_resnet_v2.py on lines 58..81

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

                                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

                                        with tf.variable_scope('Branch_2'):
                                          tower_conv2_0 = slim.conv2d(net, 64, 1, scope='Conv2d_0a_1x1')
                                          tower_conv2_1 = slim.conv2d(tower_conv2_0, 96, 3,
                                                                      scope='Conv2d_0b_3x3')
                                          tower_conv2_2 = slim.conv2d(tower_conv2_1, 96, 3,
                                Severity: Major
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 2 hrs to fix
                                research/slim/nets/inception_resnet_v2.py on lines 40..43

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

                                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

                                    with tf.variable_scope('Branch_2'):
                                      tower_conv2_0 = slim.conv2d(net, 32, 1, scope='Conv2d_0a_1x1')
                                      tower_conv2_1 = slim.conv2d(tower_conv2_0, 48, 3, scope='Conv2d_0b_3x3')
                                      tower_conv2_2 = slim.conv2d(tower_conv2_1, 64, 3, scope='Conv2d_0c_3x3')
                                Severity: Major
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 2 hrs to fix
                                research/slim/nets/inception_resnet_v2.py on lines 196..200

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

                                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

                                        if kernel_size.is_fully_defined():
                                          net = slim.avg_pool2d(net, kernel_size, padding='VALID',
                                                                scope='AvgPool_1a_8x8')
                                        else:
                                          net = tf.reduce_mean(
                                Severity: Major
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 2 hrs to fix
                                research/slim/nets/inception_v4.py on lines 320..326

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

                                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

                                        with tf.variable_scope('Branch_0'):
                                          tower_conv = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1')
                                          tower_conv_1 = slim.conv2d(tower_conv, 384, 3, stride=2,
                                Severity: Major
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 2 hrs to fix
                                research/slim/nets/inception_resnet_v2.py on lines 258..260

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

                                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

                                        with tf.variable_scope('Branch_1'):
                                          tower_conv1 = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1')
                                          tower_conv1_1 = slim.conv2d(tower_conv1, 288, 3, stride=2,
                                Severity: Major
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 2 hrs to fix
                                research/slim/nets/inception_resnet_v2.py on lines 253..255

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

                                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

                                        with tf.variable_scope('Branch_1'):
                                          tower_conv1_0 = slim.conv2d(net, 48, 1, scope='Conv2d_0a_1x1')
                                          tower_conv1_1 = slim.conv2d(tower_conv1_0, 64, 5,
                                Severity: Major
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 1 hr to fix
                                research/slim/nets/inception_resnet_v2.py on lines 37..39

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

                                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

                                    with tf.variable_scope('Branch_1'):
                                      tower_conv1_0 = slim.conv2d(net, 32, 1, scope='Conv2d_0a_1x1')
                                      tower_conv1_1 = slim.conv2d(tower_conv1_0, 32, 3, scope='Conv2d_0b_3x3')
                                Severity: Major
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 1 hr to fix
                                research/slim/nets/inception_resnet_v2.py on lines 192..194

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

                                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

                                          aux = slim.conv2d(aux, 768, aux.get_shape()[1:3],
                                Severity: Minor
                                Found in research/slim/nets/inception_resnet_v2.py and 1 other location - About 30 mins to fix
                                research/slim/nets/inception_v4.py on lines 305..306

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

                                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