tensorflow/models

View on GitHub

Showing 11,634 of 11,634 total issues

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

  def __init__(self,
               model_id: str = 'a0',
               causal: bool = False,
               use_positional_encoding: bool = False,
               conv_type: str = '3d',
Severity: Minor
Found in official/projects/movinet/modeling/movinet.py - About 45 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

Function initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(self, model: tf_keras.Model):
    """Loads pretrained checkpoint."""
    if not self.task_config.init_checkpoint:
      return

Severity: Minor
Found in official/projects/volumetric_models/tasks/semantic_segmentation_3d.py - About 45 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

Function reduce_aggregated_logs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def reduce_aggregated_logs(
      self,
      aggregated_logs: Optional[Mapping[str, Any]] = None,
      global_step: Optional[tf.Tensor] = None) -> Mapping[str, float]:
    """Reduces logs to obtain per-class metrics if needed.
Severity: Minor
Found in official/projects/volumetric_models/tasks/semantic_segmentation_3d.py - About 45 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

Function call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def call(self,
           inputs: tf.Tensor,
           states: Optional[nn_layers.States] = None
           ) -> Tuple[tf.Tensor, nn_layers.States]:
    """Calls the layer with the given inputs.
Severity: Minor
Found in official/projects/movinet/modeling/movinet_layers.py - About 45 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

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

def calculate_combined_scores_boxes_classes(

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

    def save_bbox_masks_labels(

      Avoid deeply nested control flow statements.
      Open

                if iou > iou_threshold:
                  aligned_masks += 1
                  is_similar = True
                  matched_masks_list2[j] = True
                  matched_masks_list1[i] = True

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

          def __init__(
        Severity: Minor
        Found in official/projects/maxvit/modeling/layers.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    for word in line['words']:
                      word_bnds.append(
                          np.array(word['vertices'], np.int32).reshape((-1, 1, 2)))
                      line_points_list.extend(word['vertices'])
                    paragraph_points_list.extend(line_points_list)
          Severity: Major
          Found in official/projects/unified_detector/run_inference.py - About 45 mins to fix

            Function _make_block_prunable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def _make_block_prunable(
                  self, layer: tf_keras.layers.Layer) -> tf_keras.layers.Layer:
                if isinstance(layer, tf_keras.Model):
                  return tf_keras.models.clone_model(
                      layer, input_tensors=None, clone_function=self._make_block_prunable)
            Severity: Minor
            Found in official/projects/pruning/tasks/image_classification.py - About 45 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

            Function aggregate_logs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def aggregate_logs(
                  self,
                  state: Optional[Sequence[Union[segmentation_metrics.DiceScore,
                                                 tf_keras.metrics.Metric]]] = None,
                  step_outputs: Optional[Mapping[str, Any]] = None
            Severity: Minor
            Found in official/projects/volumetric_models/tasks/semantic_segmentation_3d.py - About 45 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

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

              def __init__(self,
                           model_id: int,
                           input_specs: Mapping[str, tf.TensorShape],
                           pool_size: Sequence[int] = (2, 2, 2),
                           kernel_size: Sequence[int] = (3, 3, 3),
            Severity: Minor
            Found in official/projects/volumetric_models/modeling/decoders/unet_3d_decoder.py - About 45 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

            Function create_loop_fn has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def create_loop_fn(step_fn):
              """Creates a loop function driven by a Python `while` loop.
            
              Args:
                step_fn: A function taking a nested structure of `tf.data.Iterator` or
            Severity: Minor
            Found in orbit/utils/loop_fns.py - About 45 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

            Function build_qat_retinanet has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def build_qat_retinanet(
                model: tf_keras.Model, quantization: common.Quantization,
                model_config: configs.retinanet.RetinaNet) -> tf_keras.Model:
              """Applies quantization aware training for RetinaNet model.
            
            
            Severity: Minor
            Found in official/projects/qat/vision/modeling/factory.py - About 45 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

            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

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

                    rpn_box_encodings = tf.zeros(
                        [batch_size,
                         anchors.get_shape().as_list()[0],
                         BOX_CODE_SIZE], dtype=tf.float32)
              research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1108..1110
              research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1352..1355
              research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1533..1536
              research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1631..1634
              research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1873..1876
              research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1965..1968

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

              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

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

                def _compute_attn_output_with_global_indices(
              Severity: Minor
              Found in official/projects/longformer/longformer_attention.py - About 45 mins to fix

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

                def reindex_2d_einsum_lookup(
                Severity: Minor
                Found in official/projects/maxvit/modeling/common_ops.py - About 45 mins to fix

                  Function call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def call(
                        self,
                        inputs: tf.Tensor,
                        training: Optional[Union[bool, tf.Tensor]] = None) -> tf.Tensor:
                      """Run the InvertedBottleneckBlockNBitQuantized logics."""
                  Severity: Minor
                  Found in official/projects/qat/vision/n_bit/nn_blocks.py - About 45 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

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

                    def call(self,
                  Severity: Minor
                  Found in official/projects/qat/nlp/quantization/wrappers.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language