tensorflow/models

View on GitHub
official/projects/edgetpu/vision/modeling/mobilenet_edgetpu_v2_model_blocks.py

Summary

Maintainability
F
4 days
Test Coverage

File mobilenet_edgetpu_v2_model_blocks.py has 942 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2024 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

    Function __init__ has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def __init__(self,
                   block: BlockConfig,
                   config: ModelConfig,
                   prefix: Optional[str] = None):
        """Mobile Inverted Residual Bottleneck.

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

    def mobilenet_edgetpu_v2_base(
        width_coefficient: float = 1.0,
        depth_coefficient: float = 1.0,
        stem_base_filters: int = 64,
        stem_kernel_size: int = 5,

    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 mobilenet_edgetpu_v2_base has 12 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def mobilenet_edgetpu_v2_base(

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

      def conv2d_block(inputs: tf.Tensor,

        Function conv2d_block_as_layers has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def conv2d_block_as_layers(

          Function autoseg_edgetpu_backbone_base has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def autoseg_edgetpu_backbone_base(

            Function groupconv2d_block has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def groupconv2d_block(conv_filters: Optional[int],

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

                def from_search_config(cls,

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

                  def from_search_config(cls,
                                         input_filters: int,
                                         output_filters: int,
                                         block_search_config: BlockSearchConfig,
                                         num_repeat: int = 1,

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

                  def __call__(self, inputs: tf.Tensor, training=False):
                    x = inputs
                    for layer in self.expand_block:
                      x = layer(x)
                    if self.squeeze_excitation:

                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

                There are no issues that match your filters.

                Category
                Status