tensorflow/models

View on GitHub
official/projects/qat/vision/modeling/heads/dense_prediction_heads.py

Summary

Maintainability
D
2 days
Test Coverage

Function build has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

  def build(self, input_shape: Union[tf.TensorShape, List[tf.TensorShape]]):
    """Creates the variables of the head."""
    if self._config_dict['use_separable_conv']:
      conv_op = helper.SeparableConv2DQuantized
    else:
Severity: Minor
Found in official/projects/qat/vision/modeling/heads/dense_prediction_heads.py - About 6 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 call has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def call(self, features: Mapping[str, tf.Tensor]):
    """Forward pass of the RetinaNet quantized head.

    Args:
      features: A `dict` of `tf.Tensor` where
Severity: Minor
Found in official/projects/qat/vision/modeling/heads/dense_prediction_heads.py - About 3 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

File dense_prediction_heads.py has 325 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
Severity: Minor
Found in official/projects/qat/vision/modeling/heads/dense_prediction_heads.py - About 3 hrs to fix

    Function __init__ has 18 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def __init__(
    Severity: Major
    Found in official/projects/qat/vision/modeling/heads/dense_prediction_heads.py - About 2 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                  if prediction_tower_name not in prediction_tower_output:
                    prediction_tower_output[
                        prediction_tower_name] = build_prediction_tower(
                            att_name, this_level_features, i)
                  attributes[att_name][str(level)] = self._att_predictors[att_name](
      Severity: Major
      Found in official/projects/qat/vision/modeling/heads/dense_prediction_heads.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if level == self._config_dict['min_level']:
                      att_conv_name = '{}-conv_{}'.format(att_name, i)
                      att_convs_i.append(conv_op(name=att_conv_name, **conv_kwargs))
                    att_norm_name = '{}-conv-norm_{}_{}'.format(att_name, level, i)
        Severity: Major
        Found in official/projects/qat/vision/modeling/heads/dense_prediction_heads.py - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status