tensorflow/models

View on GitHub

Showing 11,634 of 11,634 total issues

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

    expected_output.append(
        np.reshape(np.array([[4, 7],
                             [10, 13]]),
                   (1, 2, 2, 1))
Severity: Minor
Found in research/object_detection/utils/ops_test.py and 1 other location - About 50 mins to fix
research/object_detection/utils/ops_test.py on lines 1148..1151

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

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 test_configs(self):
    cfg = configs.BERT2BERTConfig()
    cfg.validate()
    self.assertEqual(cfg.as_dict(), BERT2BERT_CONFIG)
Severity: Minor
Found in official/projects/nhnet/configs_test.py and 1 other location - About 50 mins to fix
official/projects/nhnet/configs_test.py on lines 113..116

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

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 test_nhnet_config(self):
    cfg = configs.NHNetConfig()
    cfg.validate()
    self.assertEqual(cfg.as_dict(), NHNET_CONFIG)
Severity: Minor
Found in official/projects/nhnet/configs_test.py and 1 other location - About 50 mins to fix
official/projects/nhnet/configs_test.py on lines 108..111

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

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 test_returns_correct_shapes_128(self):
    image_height = 128
    image_width = 128
    expected_feature_map_shape = (
        _SLIM_ENDPOINT_SHAPES_128)
research/object_detection/models/keras_models/inception_resnet_v2_tf2_test.py on lines 199..206

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

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

  def testResizeImageRoundingWorks(self, max_image_size, min_image_size,
Severity: Minor
Found in research/delf/delf/python/utils_test.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

              if FLAGS.debug:
                if global_step_value % report_interval == 0:
                  print(global_step.numpy())
                  print('desc:', desc_dist_loss.numpy())
                  print('attn:', attn_dist_loss.numpy())
    Severity: Major
    Found in research/delf/delf/python/training/train.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if i > 100:
                  return
              lHats.append(lHat)
      Severity: Major
      Found in research/rebar/rebar_train.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if len(prediction_split) != 2:
                    raise ValueError('Prediction is malformed: there should only be 2 '
                                     'elements in second column, but found %d for test '
                                     'image %s' % (len(prediction_split), test_id))
        
        

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

            def testResizeImageWorks(self, max_image_size, min_image_size, resize_factor,
          Severity: Minor
          Found in research/delf/delf/python/utils_test.py - About 45 mins to fix

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

            def MeanMedianPosition(predictions, retrieval_solution, max_predictions=100):
              """Computes mean and median positions of first correct image.
            
              Args:
                predictions: Dict mapping test image ID to a list of strings corresponding
            Severity: Minor
            Found in research/delf/delf/python/datasets/google_landmarks_dataset/metrics.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 FLAGS.use_autoencoder:
                        tf.summary.scalar(
                            'loss/recon/mse', recon_dist_loss, step=global_step)
            
            
            Severity: Major
            Found in research/delf/delf/python/training/train.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if (global_step_value % save_interval
                            == 0) or (global_step_value >= max_iters):
                          save_path = manager.save(checkpoint_number=global_step_value)
                          logging.info('Saved (%d) at %s', global_step_value, save_path)
              
              
              Severity: Major
              Found in research/delf/delf/python/training/train.py - About 45 mins to fix

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

                def train(sbn, train_xs, valid_xs, test_xs, training_steps, debug=False):
                Severity: Minor
                Found in research/rebar/rebar_train.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if row[1]:
                              for landmark_id in row[1].split(' '):
                                ground_truth_ids.append(int(landmark_id))
                          elif task == RETRIEVAL_TASK_ID:

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

                    def WriteToFile(file_path,
                    Severity: Minor
                    Found in research/delf/delf/python/feature_io.py - About 45 mins to fix

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

                      def extract_global_descriptors_from_list(net, images, image_size,
                                                               bounding_boxes=None, scales=[1.],
                                                               multi_scale_power=1., print_freq=10):
                        """Extracting global descriptors from a list of images.
                      
                      
                      Severity: Minor
                      Found in research/delf/delf/python/training/model/global_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 ApplyPcaAndWhitening has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def ApplyPcaAndWhitening(data,
                      Severity: Minor
                      Found in research/delf/delf/python/feature_extractor.py - About 45 mins to fix

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

                        def _build_train_tfrecord_dataset(csv_path,
                        Severity: Minor
                        Found in research/delf/delf/python/training/build_image_dataset.py - About 45 mins to fix

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

                            def __init__(self,
                          Severity: Minor
                          Found in research/delf/delf/python/training/model/resnet50.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                      if global_step_value % eval_interval == 0:
                                        for i in range(num_eval_batches):
                                          try:
                                            validation_batch = next(validation_iter)
                                            desc_validation_result, attn_validation_result = (
                            Severity: Major
                            Found in research/delf/delf/python/training/train.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language