tensorflow/models

View on GitHub

Showing 11,634 of 11,634 total issues

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

def _create_fake_bert_dataset(
    output_path,
    seq_length,
    max_predictions_per_seq,
    use_position_id,
Severity: Minor
Found in official/nlp/data/pretrain_dataloader_test.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 _generate_detections_per_image has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def _generate_detections_per_image(boxes,
Severity: Minor
Found in official/legacy/detection/ops/postprocess_ops.py - About 45 mins to fix

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

    def crop_mask_in_target_box(masks,
    Severity: Minor
    Found in official/legacy/detection/ops/spatial_transform_ops.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                for j in range(a_end, len(current_chunk)):
                  tokens_b.extend(current_chunk[j])
              truncate_seq_pair(tokens_a, tokens_b, max_num_tokens, rng)
      Severity: Major
      Found in official/nlp/data/create_pretraining_data.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if version_2_with_negative:
                    is_impossible = qa["is_impossible"]
                  if (len(qa["answers"]) != 1) and (not is_impossible):
        Severity: Major
        Found in official/nlp/data/squad_lib.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    if (len(qa["answers"]) != 1) and (not is_impossible):
                      raise ValueError(
                          "For training, each question should have exactly 1 answer.")
                    if not is_impossible:
          Severity: Major
          Found in official/nlp/data/squad_lib.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if use_batched_nms:
                        this_level_rois, this_level_roi_scores, _, _ = (
                            tf.image.combined_non_max_suppression(
                                tf.expand_dims(this_level_boxes, axis=2),
                                tf.expand_dims(this_level_scores, axis=-1),
            Severity: Major
            Found in official/legacy/detection/ops/roi_ops.py - About 45 mins to fix

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

                def _build_box_net_layers(self, norm_activation):
                  """Build re-usable layers for box prediction network."""
                  if self._use_separable_conv:
                    self._box_predict = tf_keras.layers.SeparableConv2D(
                        4 * self._anchors_per_location,
              Severity: Minor
              Found in official/legacy/detection/modeling/architecture/heads.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_outputs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def build_outputs(self, inputs, mode):
                  is_training = mode == mode_keys.TRAIN
                  images = inputs['image']
              
                  if 'anchor_boxes' in inputs:
              Severity: Minor
              Found in official/legacy/detection/modeling/shapemask_model.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 ious[dind, gind] < iou:
                            continue
                          # if match successful and best so far, store appropriately
                          iou = ious[dind, gind]
              Severity: Major
              Found in official/legacy/detection/evaluation/coco_evaluator.py - About 45 mins to fix

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

                  def build_input_layers(self, params, mode):
                    is_training = mode == mode_keys.TRAIN
                    input_shape = (
                        params.maskrcnn_parser.output_size +
                        [params.maskrcnn_parser.num_channels])
                Severity: Minor
                Found in official/legacy/detection/modeling/maskrcnn_model.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_input_layers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def build_input_layers(self, params, mode):
                    is_training = mode == mode_keys.TRAIN
                    input_shape = (
                        params.olnmask_parser.output_size +
                        [params.olnmask_parser.num_channels])
                Severity: Minor
                Found in official/legacy/detection/modeling/olnmask_model.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 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def __init__(self,
                Severity: Minor
                Found in official/legacy/detection/modeling/architecture/heads.py - About 45 mins to fix

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

                  def create_optimizer(init_lr,
                  Severity: Minor
                  Found in official/legacy/xlnet/optimization.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                              if length > max_answer_length:
                                continue
                    
                    
                    Severity: Major
                    Found in official/legacy/xlnet/squad_utils.py - About 45 mins to fix

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

                      def run(callbacks=None):
                        """Runs the experiment."""
                        keras_utils.set_session_config(enable_xla=FLAGS.enable_xla)
                      
                        params = config_factory.config_generator(FLAGS.model)
                      Severity: Minor
                      Found in official/legacy/detection/main.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 'areas' not in groundtruths:
                                  ann['area'] = mask_api.area(encoded_mask)
                              gt_annotations.append(ann)
                      Severity: Major
                      Found in official/legacy/detection/evaluation/coco_utils.py - About 45 mins to fix

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

                          def _run_evaluation(self, test_step, current_training_step, metric,
                                              test_iterator):
                            """Runs validation steps and aggregate metrics."""
                            self.eval_steps.assign(0)
                            if not test_iterator or not metric:
                        Severity: Minor
                        Found in official/legacy/detection/executor/detection_executor.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 _block_group has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          def _block_group(self,
                        Severity: Minor
                        Found in official/legacy/detection/modeling/architecture/spinenet.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                      if m > -1 and gt_ig[m] == 0 and gt_ig[gind] == 1:
                                        break
                                      # continue to next gt unless better match made
                                      if ious[dind, gind] < iou:
                          Severity: Major
                          Found in official/legacy/detection/evaluation/coco_evaluator.py - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language