tensorflow/tensorflow

View on GitHub
tensorflow/python/keras/engine/training.py

Summary

Maintainability
F
3 wks
Test Coverage

File training.py has 2435 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2015 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: Major
Found in tensorflow/python/keras/engine/training.py - About 6 days to fix

    Model has 64 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Model(base_layer.Layer, version_utils.ModelVersionSelector):
      """`Model` groups layers into an object with training and inference features.
    
      Args:
          inputs: The input(s) of the model: a `keras.Input` object or list of
    Severity: Major
    Found in tensorflow/python/keras/engine/training.py - About 1 day to fix

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

        def build(self, input_shape):
          """Builds the model based on input shapes received.
      
          This is to be used for subclassed models, which do not know at instantiation
          time what their inputs look like.
      Severity: Minor
      Found in tensorflow/python/keras/engine/training.py - About 4 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 fit has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        def fit(self,
                x=None,
                y=None,
                batch_size=None,
                epochs=1,
      Severity: Minor
      Found in tensorflow/python/keras/engine/training.py - About 4 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 _validate_compile has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        def _validate_compile(self, optimizer, metrics, **kwargs):
          """Performs validation checks for the default `compile`."""
          if any(
              isinstance(opt, optimizer_v1.Optimizer)
              for opt in nest.flatten(optimizer)):
      Severity: Minor
      Found in tensorflow/python/keras/engine/training.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

      Function load_weights has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        def load_weights(self,
                         filepath,
                         by_name=False,
                         skip_mismatch=False,
                         options=None):
      Severity: Minor
      Found in tensorflow/python/keras/engine/training.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

      Function save_weights has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        def save_weights(self,
                         filepath,
                         overwrite=True,
                         save_format=None,
                         options=None):
      Severity: Minor
      Found in tensorflow/python/keras/engine/training.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

      Function predict has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        def predict(self,
                    x,
                    batch_size=None,
                    verbose=0,
                    steps=None,
      Severity: Minor
      Found in tensorflow/python/keras/engine/training.py - About 2 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 __init__ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def __init__(self, *args, **kwargs):
          self._is_model_for_instrumentation = True
      
          # Special case for Subclassed Functional Model, which we couldn't detect
          # when __new__ is called. We only realize it is a functional model when it
      Severity: Minor
      Found in tensorflow/python/keras/engine/training.py - About 2 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 fit has 19 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def fit(self,
      Severity: Major
      Found in tensorflow/python/keras/engine/training.py - About 2 hrs to fix

        Function fit_generator has 14 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def fit_generator(self,
        Severity: Major
        Found in tensorflow/python/keras/engine/training.py - About 1 hr to fix

          Function evaluate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def evaluate(self,
                         x=None,
                         y=None,
                         batch_size=None,
                         verbose=1,
          Severity: Minor
          Found in tensorflow/python/keras/engine/training.py - About 1 hr 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 evaluate has 12 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def evaluate(self,
          Severity: Major
          Found in tensorflow/python/keras/engine/training.py - About 1 hr to fix

            Function get_layer has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def get_layer(self, name=None, index=None):
                """Retrieves a layer based on either its name (unique) or index.
            
                If `name` and `index` are both provided, `index` will take precedence.
                Indices are based on order of horizontal graph traversal (bottom-up).
            Severity: Minor
            Found in tensorflow/python/keras/engine/training.py - About 1 hr 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_per_replica has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def reduce_per_replica(values, strategy, reduction='first'):
              """Reduce PerReplica objects.
            
              Args:
                values: Structure of `PerReplica` objects or `Tensor`s. `Tensor`s are
            Severity: Minor
            Found in tensorflow/python/keras/engine/training.py - About 1 hr 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 _get_optimizer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def _get_optimizer(self, optimizer):
                """Wraps `optimizer` in `LossScaleOptimizer` if necessary."""
                # The deprecated PolicyV1 has a loss_scale, which we use for backwards
                # compatibility to match TF 2.3 behavior. The new Policy does not have a
                # loss_scale, so we use dynamic loss scaling if the mixed_float16 policy is
            Severity: Minor
            Found in tensorflow/python/keras/engine/training.py - About 1 hr 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 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def __init__(self, *args, **kwargs):
                self._is_model_for_instrumentation = True
            
                # Special case for Subclassed Functional Model, which we couldn't detect
                # when __new__ is called. We only realize it is a functional model when it
            Severity: Minor
            Found in tensorflow/python/keras/engine/training.py - About 1 hr to fix

              Function predict has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def predict(self,
              Severity: Major
              Found in tensorflow/python/keras/engine/training.py - About 1 hr to fix

                Function compile has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def compile(self,
                Severity: Major
                Found in tensorflow/python/keras/engine/training.py - About 1 hr to fix

                  Function predict_generator has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def predict_generator(self,
                  Severity: Major
                  Found in tensorflow/python/keras/engine/training.py - About 50 mins to fix

                    Function save has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def save(self,
                    Severity: Major
                    Found in tensorflow/python/keras/engine/training.py - About 50 mins to fix

                      Function evaluate_generator has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def evaluate_generator(self,
                      Severity: Major
                      Found in tensorflow/python/keras/engine/training.py - About 50 mins to fix

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

                          def make_test_function(self):
                            """Creates a function that executes one step of evaluation.
                        
                            This method can be overridden to support custom evaluation logic.
                            This method is called by `Model.evaluate` and `Model.test_on_batch`.
                        Severity: Minor
                        Found in tensorflow/python/keras/engine/training.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 make_train_function has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def make_train_function(self):
                            """Creates a function that executes one step of training.
                        
                            This method can be overridden to support custom training logic.
                            This method is called by `Model.fit` and `Model.train_on_batch`.
                        Severity: Minor
                        Found in tensorflow/python/keras/engine/training.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 _set_save_spec has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def _set_save_spec(self, inputs):
                            if self._saved_model_inputs_spec is not None:
                              return  # Already set.
                        
                            input_names = self.input_names
                        Severity: Minor
                        Found in tensorflow/python/keras/engine/training.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 outputs is None:
                                      outputs = nest.map_structure(lambda batch_output: [batch_output],
                                                                   batch_outputs)
                                    else:
                                      nest.map_structure_up_to(
                        Severity: Major
                        Found in tensorflow/python/keras/engine/training.py - About 45 mins to fix

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

                            def train_on_batch(self,
                          Severity: Minor
                          Found in tensorflow/python/keras/engine/training.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        if arg == 'training':
                                          # Case where `training` is a positional arg with no default.
                                          kwargs['training'] = False
                                        else:
                                          # Has invalid call signature with unknown positional arguments.
                            Severity: Major
                            Found in tensorflow/python/keras/engine/training.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          with trace.Trace('test', step_num=step, _r=1):
                                            callbacks.on_test_batch_begin(step)
                                            tmp_logs = self.test_function(iterator)
                                            if data_handler.should_sync:
                                              context.async_wait()
                              Severity: Major
                              Found in tensorflow/python/keras/engine/training.py - About 45 mins to fix

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

                                  def make_predict_function(self):
                                    """Creates a function that executes one step of inference.
                                
                                    This method can be overridden to support custom inference logic.
                                    This method is called by `Model.predict` and `Model.predict_on_batch`.
                                Severity: Minor
                                Found in tensorflow/python/keras/engine/training.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

                                            with trace.Trace(
                                                'train',
                                                epoch_num=epoch,
                                                step_num=step,
                                                batch_size=batch_size,
                                Severity: Major
                                Found in tensorflow/python/keras/engine/training.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                              if data_handler.should_sync:
                                                context.async_wait()
                                              batch_outputs = tmp_batch_outputs  # No error, now safe to assign.
                                  Severity: Major
                                  Found in tensorflow/python/keras/engine/training.py - About 45 mins to fix

                                    Function test_on_batch has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                      def test_on_batch(self,
                                    Severity: Minor
                                    Found in tensorflow/python/keras/engine/training.py - About 35 mins to fix

                                      Function flatten_metrics_in_order has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      def flatten_metrics_in_order(logs, metrics_names):
                                        """Turns the `logs` dict into a list as per key order of `metrics_names`."""
                                        results = []
                                        for name in metrics_names:
                                          if name in logs:
                                      Severity: Minor
                                      Found in tensorflow/python/keras/engine/training.py - About 35 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 _detect_save_format has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      def _detect_save_format(filepath):
                                        """Returns path to weights file and save format."""
                                      
                                        filepath = path_to_string(filepath)
                                        if saving_utils.is_hdf5_filepath(filepath):
                                      Severity: Minor
                                      Found in tensorflow/python/keras/engine/training.py - About 35 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 too many return statements within this function.
                                      Open

                                              return concat(strategy.unwrap(v))
                                      Severity: Major
                                      Found in tensorflow/python/keras/engine/training.py - About 30 mins to fix

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

                                          def metrics(self):
                                            """Returns the model's metrics added using `compile`, `add_metric` APIs.
                                        
                                            Note: Metrics passed to `compile()` are available only after a `keras.Model`
                                            has been trained/evaluated on actual data.
                                        Severity: Minor
                                        Found in tensorflow/python/keras/engine/training.py - About 25 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 state_updates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def state_updates(self):
                                            """Deprecated, do NOT use!
                                        
                                            Returns the `updates` from all layers that are stateful.
                                        
                                        
                                        Severity: Minor
                                        Found in tensorflow/python/keras/engine/training.py - About 25 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

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

                                          def _check_call_args(self, method_name):
                                            """Check that `call` has only one positional arg."""
                                            # Always allow first arg, regardless of arg name.
                                            fullargspec = self._call_full_argspec
                                            if fullargspec.defaults:
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 1 day to fix
                                        tensorflow/python/keras/engine/training_v1.py on lines 1316..1333

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

                                        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 step_function(model, iterator):
                                              """Runs a single evaluation step."""
                                        
                                              def run_step(data):
                                                outputs = model.predict_step(data)
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 6 hrs to fix
                                        tensorflow/python/keras/engine/training.py on lines 1307..1321

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

                                        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 step_function(model, iterator):
                                              """Runs a single evaluation step."""
                                        
                                              def run_step(data):
                                                outputs = model.test_step(data)
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 6 hrs to fix
                                        tensorflow/python/keras/engine/training.py on lines 1556..1570

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

                                        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 fit_generator(self,
                                                            generator,
                                                            steps_per_epoch=None,
                                                            epochs=1,
                                                            verbose=1,
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 5 hrs to fix
                                        tensorflow/python/keras/engine/training_v1.py on lines 1222..1246

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

                                        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

                                            if self._steps_per_execution.numpy().item() == 1:
                                        
                                              def train_function(iterator):
                                                """Runs a training execution with one step."""
                                                return step_function(self, iterator)
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 4 hrs to fix
                                        tensorflow/python/keras/engine/training.py on lines 1323..1335

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

                                        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

                                            if self._steps_per_execution.numpy().item() == 1:
                                        
                                              def test_function(iterator):
                                                """Runs an evaluation execution with one step."""
                                                return step_function(self, iterator)
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 4 hrs to fix
                                        tensorflow/python/keras/engine/training.py on lines 853..865

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

                                        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

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

                                          def evaluate_generator(self,
                                                                 generator,
                                                                 steps=None,
                                                                 callbacks=None,
                                                                 max_queue_size=10,
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 3 hrs to fix
                                        tensorflow/python/keras/engine/training_v1.py on lines 1262..1281

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

                                        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

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

                                          def predict_generator(self,
                                                                generator,
                                                                steps=None,
                                                                callbacks=None,
                                                                max_queue_size=10,
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 2 hrs to fix
                                        tensorflow/python/keras/engine/training_v1.py on lines 1290..1307

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

                                        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

                                            for metric in nest.flatten(metrics):
                                              for v in getattr(metric, 'variables', []):
                                                if not strategy.extended.variable_created_in_scope(v):
                                                  raise ValueError(
                                                      'Metric (%s) passed to model.compile was created inside of a '
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 2 hrs to fix
                                        tensorflow/python/keras/engine/training.py on lines 2685..2695

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

                                        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

                                            for opt in nest.flatten(optimizer):
                                              for v in getattr(opt, '_weights', []):
                                                if not strategy.extended.variable_created_in_scope(v):
                                                  raise ValueError(
                                                      'Optimizer (%s) passed to model.compile was created inside of a '
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 2 hrs to fix
                                        tensorflow/python/keras/engine/training.py on lines 2670..2680

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

                                        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

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

                                              if not isinstance(callbacks, callbacks_module.CallbackList):
                                                callbacks = callbacks_module.CallbackList(
                                                    callbacks,
                                                    add_history=True,
                                                    add_progbar=verbose != 0,
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 2 hrs to fix
                                        tensorflow/python/keras/engine/training.py on lines 1723..1731

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

                                        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

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

                                              if not isinstance(callbacks, callbacks_module.CallbackList):
                                                callbacks = callbacks_module.CallbackList(
                                                    callbacks,
                                                    add_history=True,
                                                    add_progbar=verbose != 0,
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 2 hrs to fix
                                        tensorflow/python/keras/engine/training.py on lines 1477..1485

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

                                        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

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

                                            if backend.is_tpu_strategy(self._distribution_strategy):
                                              if (self._distribution_strategy.extended.steps_per_run > 1 and
                                                  (not saving_utils.is_hdf5_filepath(filepath))):
                                                raise ValueError('Load weights is not yet supported with TPUStrategy '
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 2 hrs to fix
                                        tensorflow/python/keras/engine/training_v1.py on lines 228..231

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

                                        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

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

                                            for metric in self.metrics:
                                              result = metric.result()
                                              if isinstance(result, dict):
                                                return_metrics.update(result)
                                              else:
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 1 hr to fix
                                        tensorflow/python/keras/engine/training.py on lines 805..810

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

                                        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

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

                                            for metric in self.metrics:
                                              result = metric.result()
                                              if isinstance(result, dict):
                                                return_metrics.update(result)
                                              else:
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 1 hr to fix
                                        tensorflow/python/keras/engine/training.py on lines 1277..1282

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

                                        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

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

                                            if isinstance(self._dtype_policy, policy.PolicyV1):
                                              loss_scale = self._dtype_policy.loss_scale
                                            elif self._dtype_policy.name == 'mixed_float16':
                                              loss_scale = 'dynamic'
                                            else:
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 1 hr to fix
                                        tensorflow/python/keras/engine/training_v1.py on lines 1349..1354

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

                                        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

                                              if len(self.layers) <= index:
                                                raise ValueError('Was asked to retrieve layer at index ' + str(index) +
                                                                 ' but model only has ' + str(len(self.layers)) +
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 1 hr to fix
                                        tensorflow/python/keras/engine/functional.py on lines 427..429

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

                                        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

                                            if not overwrite and os.path.isfile(check_filepath):
                                              proceed = ask_to_proceed_with_overwrite(check_filepath)
                                              if not proceed:
                                        Severity: Major
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 1 hr to fix
                                        tensorflow/python/keras/saving/saved_model/save.py on lines 67..69

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

                                        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

                                            if self._cluster_coordinator:
                                              self.train_function = lambda iterator: self._cluster_coordinator.schedule(  # pylint: disable=g-long-lambda
                                                  train_function, args=(iterator,))
                                        Severity: Minor
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 35 mins to fix
                                        tensorflow/python/keras/engine/training.py on lines 1343..1345

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

                                        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

                                            if self._cluster_coordinator:
                                              self.test_function = lambda iterator: self._cluster_coordinator.schedule(  # pylint: disable=g-long-lambda
                                                  test_function, args=(iterator,))
                                        Severity: Minor
                                        Found in tensorflow/python/keras/engine/training.py and 1 other location - About 35 mins to fix
                                        tensorflow/python/keras/engine/training.py on lines 874..876

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

                                        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

                                        There are no issues that match your filters.

                                        Category
                                        Status