tensorflow/tensorflow

View on GitHub
tensorflow/python/keras/callbacks.py

Summary

Maintainability
F
2 wks
Test Coverage

File callbacks.py has 2267 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/callbacks.py - About 6 days to fix

    Function _save_model has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

      def _save_model(self, epoch, logs):
        """Saves the model.
    
        Args:
            epoch: the epoch this iteration is in.
    Severity: Minor
    Found in tensorflow/python/keras/callbacks.py - About 6 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    TensorBoard has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TensorBoard(Callback, version_utils.TensorBoardVersionSelector):
      # pylint: disable=line-too-long
      """Enable visualizations for TensorBoard.
    
      TensorBoard is a visualization tool provided with TensorFlow.
    Severity: Minor
    Found in tensorflow/python/keras/callbacks.py - About 4 hrs to fix

      CallbackList has 30 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class CallbackList:
        """Container abstracting a list of callbacks."""
      
        def __init__(self,
                     callbacks=None,
      Severity: Minor
      Found in tensorflow/python/keras/callbacks.py - About 3 hrs to fix

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

          def __init__(self,
                       filepath,
                       monitor='val_loss',
                       verbose=0,
                       save_best_only=False,
        Severity: Minor
        Found in tensorflow/python/keras/callbacks.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 _get_most_recently_modified_file_matching_pattern has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          def _get_most_recently_modified_file_matching_pattern(self, pattern):
            """Returns the most recently modified filepath matching pattern.
        
            Pattern may contain python formatting placeholder. If
            `tf.train.latest_checkpoint()` does not return None, use that; otherwise,
        Severity: Minor
        Found in tensorflow/python/keras/callbacks.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 on_epoch_end has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          def on_epoch_end(self, epoch, logs=None):
            logs = logs or {}
            logs['lr'] = backend.get_value(self.model.optimizer.lr)
            current = logs.get(self.monitor)
            if current is None:
        Severity: Minor
        Found in tensorflow/python/keras/callbacks.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 _configure_embeddings has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def _configure_embeddings(self):
            """Configure the Projector for embeddings."""
            # TODO(omalleyt): Add integration tests.
            from google.protobuf import text_format
            from tensorflow.python.keras.layers import embeddings
        Severity: Minor
        Found in tensorflow/python/keras/callbacks.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

        Callback has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Callback:
          """Abstract base class used to build new callbacks.
        
          Callbacks can be passed to keras methods such as `fit`, `evaluate`, and
          `predict` in order to hook into the various stages of the model training and
        Severity: Minor
        Found in tensorflow/python/keras/callbacks.py - About 2 hrs to fix

          Function on_epoch_end has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def on_epoch_end(self, epoch, logs=None):
              current = self.get_monitor_value(logs)
              if current is None:
                return
              if self.restore_best_weights and self.best_weights is None:
          Severity: Minor
          Found in tensorflow/python/keras/callbacks.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 _disallow_batch_hooks_in_ps_strategy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def _disallow_batch_hooks_in_ps_strategy(self):
              """Error out if batch-level callbacks are passed with PSStrategy."""
              # pylint: disable=protected-access
              strategy = distribute_lib.get_strategy()
              if strategy._should_use_with_coordinator:
          Severity: Minor
          Found in tensorflow/python/keras/callbacks.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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def __init__(self,
                         on_epoch_begin=None,
                         on_epoch_end=None,
                         on_batch_begin=None,
                         on_batch_end=None,
          Severity: Minor
          Found in tensorflow/python/keras/callbacks.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 on_epoch_end has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def on_epoch_end(self, epoch, logs=None):
              logs = logs or {}
          
              def handle_value(k):
                is_zero_dim_ndarray = isinstance(k, np.ndarray) and k.ndim == 0
          Severity: Minor
          Found in tensorflow/python/keras/callbacks.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 configure_callbacks has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def configure_callbacks(callbacks,
          Severity: Major
          Found in tensorflow/python/keras/callbacks.py - About 1 hr to fix

            Function on_epoch_end has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def on_epoch_end(self, epoch, logs=None):
                if logs is not None:
                  for k in self.params['metrics']:
                    if k in self.totals:
                      # Make value available to next callbacks.
            Severity: Minor
            Found in tensorflow/python/keras/callbacks.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 10 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

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

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

                Function set_callback_parameters has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def set_callback_parameters(callback_list,
                Severity: Major
                Found in tensorflow/python/keras/callbacks.py - About 1 hr to fix

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

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

                    Function _init_profile_batch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def _init_profile_batch(self, profile_batch):
                        """Validate profile_batch value and set the range of batches to profile.
                        Sets values of _start_batch and _stop_batch attributes,
                        specifying the start and stop batch to profile.
                        Setting `profile_batch=0` disables profiling.
                    Severity: Minor
                    Found in tensorflow/python/keras/callbacks.py - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

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

                      def __init__(self,
                                   monitor='val_loss',
                                   min_delta=0,
                                   patience=0,
                                   verbose=0,
                    Severity: Minor
                    Found in tensorflow/python/keras/callbacks.py - About 55 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 _log_weight_as_image has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def _log_weight_as_image(self, weight, weight_name, epoch):
                        """Logs a weight as a TensorBoard image."""
                        w_img = array_ops.squeeze(weight)
                        shape = backend.int_shape(w_img)
                        if len(shape) == 1:  # Bias case
                    Severity: Minor
                    Found in tensorflow/python/keras/callbacks.py - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

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

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

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

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

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

                          def on_batch_end(self, batch, logs=None):
                            logs = logs or {}
                            batch_size = logs.get('size', 0)
                            # In case of distribution strategy we can potentially run multiple steps
                            # at the same time, we should account for that in the `seen` calculation.
                        Severity: Minor
                        Found in tensorflow/python/keras/callbacks.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 self.verbose > 0:
                                        print('\nEpoch %05d: %s improved from %0.5f to %0.5f,'
                                              ' saving model to %s' % (epoch + 1, self.monitor,
                                                                       self.best, current, filepath))
                                      self.best = current
                        Severity: Major
                        Found in tensorflow/python/keras/callbacks.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if self.save_weights_only:
                                          self.model.save_weights(
                                              filepath, overwrite=True, options=self._options)
                                        else:
                                          self.model.save(filepath, overwrite=True, options=self._options)
                          Severity: Major
                          Found in tensorflow/python/keras/callbacks.py - About 45 mins to fix

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

                              def on_epoch_end(self, epoch, logs=None):
                                if requests is None:
                                  raise ImportError('RemoteMonitor requires the `requests` library.')
                                logs = logs or {}
                                send = {}
                            Severity: Minor
                            Found in tensorflow/python/keras/callbacks.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 _log_epoch_metrics has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def _log_epoch_metrics(self, epoch, logs):
                                """Writes epoch metrics out as scalar summaries.
                            
                                Args:
                                    epoch: Int. The global step to use for TensorBoard.
                            Severity: Minor
                            Found in tensorflow/python/keras/callbacks.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 self.verbose > 0:
                                            print('\nEpoch %05d: %s did not improve from %0.5f' %
                                                  (epoch + 1, self.monitor, self.best))
                                    else:
                            Severity: Major
                            Found in tensorflow/python/keras/callbacks.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if layer.name in self.embeddings_metadata.keys():
                                            embedding.metadata_path = self.embeddings_metadata.pop(layer.name)
                              
                              
                              Severity: Major
                              Found in tensorflow/python/keras/callbacks.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if self.write_images:
                                              self._log_weight_as_image(weight, weight_name, epoch)
                                        self._train_writer.flush()
                                Severity: Major
                                Found in tensorflow/python/keras/callbacks.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                              if self.verbose > 0:
                                                print('\nEpoch %05d: ReduceLROnPlateau reducing learning '
                                                      'rate to %s.' % (epoch + 1, new_lr))
                                              self.cooldown_counter = self.cooldown
                                  Severity: Major
                                  Found in tensorflow/python/keras/callbacks.py - About 45 mins to fix

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

                                    def make_logs(model, logs, outputs, mode, prefix=''):
                                    Severity: Minor
                                    Found in tensorflow/python/keras/callbacks.py - About 35 mins to fix

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

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

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

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

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

                                            def _add_default_callbacks(self, add_history, add_progbar):
                                              """Adds `Callback`s that are always present."""
                                              self._progbar = None
                                              self._history = None
                                          
                                          
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.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 on_train_begin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                            def on_train_begin(self, logs=None):
                                              if self.load_weights_on_restart:
                                                filepath_to_load = (
                                                    self._get_most_recently_modified_file_matching_pattern(self.filepath))
                                                if (filepath_to_load is not None and
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.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 set_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                            def set_params(self, params):
                                              self.verbose = params['verbose']
                                              self.epochs = params['epochs']
                                              if self.use_steps and 'steps' in params:
                                                self.target = params['steps']
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.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 configure_callbacks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                          def configure_callbacks(callbacks,
                                                                  model,
                                                                  do_validation=False,
                                                                  batch_size=None,
                                                                  epochs=None,
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.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 _log_weights has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                            def _log_weights(self, epoch):
                                              """Logs the weights of the Model to TensorBoard."""
                                              with self._train_writer.as_default():
                                                with summary_ops_v2.record_if(True):
                                                  for layer in self.model.layers:
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.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 _finalize_progbar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                            def _finalize_progbar(self, logs, counter):
                                              logs = tf_utils.sync_to_numpy_or_python_type(logs or {})
                                              if self.target is None:
                                                if counter is not None:
                                                  counter = counter.numpy()
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.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 _call_batch_end_hook has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                            def _call_batch_end_hook(self, mode, batch, logs):
                                              """Helper function for `on_*_batch_end` methods."""
                                              hook_name = 'on_{mode}_batch_end'.format(mode=mode)
                                          
                                              if self._check_timing and batch >= 1:
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.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 set_callback_parameters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                          def set_callback_parameters(callback_list,
                                                                      model,
                                                                      do_validation=False,
                                                                      batch_size=None,
                                                                      epochs=None,
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.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 on_epoch_begin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                            def on_epoch_begin(self, epoch, logs=None):
                                              if not hasattr(self.model.optimizer, 'lr'):
                                                raise ValueError('Optimizer must have a "lr" attribute.')
                                              try:  # new API
                                                lr = float(backend.get_value(self.model.optimizer.lr))
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.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

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

                                              elif len(shape) == 3:  # ConvNet case
                                                if backend.image_data_format() == 'channels_last':
                                                  # Switch to channels_first to display every kernel as a separate
                                                  # image.
                                                  w_img = array_ops.transpose(w_img, perm=[2, 0, 1])
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 4 hrs to fix
                                          tensorflow/python/keras/callbacks_v1.py on lines 192..199

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

                                          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

                                              elif len(shape) == 2:  # Dense layer kernel case
                                                if shape[0] > shape[1]:
                                                  w_img = array_ops.transpose(w_img)
                                                  shape = backend.int_shape(w_img)
                                                w_img = array_ops.reshape(w_img, [1, shape[0], shape[1], 1])
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 4 hrs to fix
                                          tensorflow/python/keras/callbacks_v1.py on lines 187..191

                                          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

                                            def _call_end_hook(self, mode):
                                              """Helper function for on_{train|test|predict}_end methods."""
                                              if mode == ModeKeys.TRAIN:
                                                self.on_train_end()
                                              elif mode == ModeKeys.TEST:
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 2 hrs to fix
                                          tensorflow/python/keras/callbacks.py on lines 380..387

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

                                          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 _call_begin_hook(self, mode):
                                              """Helper function for on_{train|test|predict}_begin methods."""
                                              if mode == ModeKeys.TRAIN:
                                                self.on_train_begin()
                                              elif mode == ModeKeys.TEST:
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 2 hrs to fix
                                          tensorflow/python/keras/callbacks.py on lines 389..396

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

                                          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

                                            @property
                                            def _val_writer(self):
                                              if 'val' not in self._writers:
                                                self._writers['val'] = summary_ops_v2.create_file_writer_v2(self._val_dir)
                                              return self._writers['val']
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 2 hrs to fix
                                          tensorflow/python/keras/callbacks.py on lines 2230..2235

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

                                          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

                                            @property
                                            def _train_writer(self):
                                              if 'train' not in self._writers:
                                                self._writers['train'] = summary_ops_v2.create_file_writer_v2(
                                                    self._train_dir)
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 2 hrs to fix
                                          tensorflow/python/keras/callbacks.py on lines 2237..2241

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

                                          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 self.save_weights_only:
                                                      self.model.save_weights(
                                                          filepath, overwrite=True, options=self._options)
                                                    else:
                                                      self.model.save(filepath, overwrite=True, options=self._options)
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 1433..1437

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

                                          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 self.save_weights_only:
                                                          self.model.save_weights(
                                                              filepath, overwrite=True, options=self._options)
                                                        else:
                                                          self.model.save(filepath, overwrite=True, options=self._options)
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 1445..1449

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

                                          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 save_weights_only:
                                                if options is None or isinstance(
                                                    options, checkpoint_options_lib.CheckpointOptions):
                                                  self._options = options or checkpoint_options_lib.CheckpointOptions()
                                                else:
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 1295..1306

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

                                          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 on_epoch_begin(self, epoch, logs=None):
                                              """Calls the `on_epoch_begin` methods of its callbacks.
                                          
                                              This function should only be called during TRAIN mode.
                                          
                                          
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 420..433

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

                                          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 on_epoch_end(self, epoch, logs=None):
                                              """Calls the `on_epoch_end` methods of its callbacks.
                                          
                                              This function should only be called during TRAIN mode.
                                          
                                          
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 406..418

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

                                          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 _implements_test_batch_hooks(self):
                                              """Determines if this Callback should be called for each test batch."""
                                              return (not generic_utils.is_default(self.on_test_batch_begin) or
                                                      not generic_utils.is_default(self.on_test_batch_end))
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 896..899

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

                                          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 _implements_predict_batch_hooks(self):
                                              """Determines if this Callback should be called for each predict batch."""
                                              return (not generic_utils.is_default(self.on_predict_batch_begin) or
                                                      not generic_utils.is_default(self.on_predict_batch_end))
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 891..894

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

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_train_begin(self, logs=None):
                                              """Calls the `on_train_begin` methods of its callbacks.
                                          
                                              Args:
                                                  logs: Dict. Currently no data is passed to this argument for this method
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 512..521
                                          tensorflow/python/keras/callbacks.py on lines 523..532
                                          tensorflow/python/keras/callbacks.py on lines 534..543
                                          tensorflow/python/keras/callbacks.py on lines 545..554
                                          tensorflow/python/keras/callbacks.py on lines 556..565

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

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_predict_end(self, logs=None):
                                              """Calls the `on_predict_end` methods of its callbacks.
                                          
                                              Args:
                                                  logs: Dict. Currently no data is passed to this argument for this method
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 501..510
                                          tensorflow/python/keras/callbacks.py on lines 512..521
                                          tensorflow/python/keras/callbacks.py on lines 523..532
                                          tensorflow/python/keras/callbacks.py on lines 534..543
                                          tensorflow/python/keras/callbacks.py on lines 545..554

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

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_test_end(self, logs=None):
                                              """Calls the `on_test_end` methods of its callbacks.
                                          
                                              Args:
                                                  logs: Dict. Currently no data is passed to this argument for this method
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 501..510
                                          tensorflow/python/keras/callbacks.py on lines 512..521
                                          tensorflow/python/keras/callbacks.py on lines 523..532
                                          tensorflow/python/keras/callbacks.py on lines 545..554
                                          tensorflow/python/keras/callbacks.py on lines 556..565

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

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_train_end(self, logs=None):
                                              """Calls the `on_train_end` methods of its callbacks.
                                          
                                              Args:
                                                  logs: Dict. Currently no data is passed to this argument for this method
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 501..510
                                          tensorflow/python/keras/callbacks.py on lines 523..532
                                          tensorflow/python/keras/callbacks.py on lines 534..543
                                          tensorflow/python/keras/callbacks.py on lines 545..554
                                          tensorflow/python/keras/callbacks.py on lines 556..565

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

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_predict_begin(self, logs=None):
                                              """Calls the 'on_predict_begin` methods of its callbacks.
                                          
                                              Args:
                                                  logs: Dict. Currently no data is passed to this argument for this method
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 501..510
                                          tensorflow/python/keras/callbacks.py on lines 512..521
                                          tensorflow/python/keras/callbacks.py on lines 523..532
                                          tensorflow/python/keras/callbacks.py on lines 534..543
                                          tensorflow/python/keras/callbacks.py on lines 556..565

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

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_test_begin(self, logs=None):
                                              """Calls the `on_test_begin` methods of its callbacks.
                                          
                                              Args:
                                                  logs: Dict. Currently no data is passed to this argument for this method
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 1 hr to fix
                                          tensorflow/python/keras/callbacks.py on lines 501..510
                                          tensorflow/python/keras/callbacks.py on lines 512..521
                                          tensorflow/python/keras/callbacks.py on lines 534..543
                                          tensorflow/python/keras/callbacks.py on lines 545..554
                                          tensorflow/python/keras/callbacks.py on lines 556..565

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

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_predict_batch_end(self, batch, logs=None):
                                              """Calls the `on_predict_batch_end` methods of its callbacks.
                                          
                                              Args:
                                                  batch: Integer, index of batch within the current epoch.
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 50 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 435..445
                                          tensorflow/python/keras/callbacks.py on lines 447..455
                                          tensorflow/python/keras/callbacks.py on lines 457..467
                                          tensorflow/python/keras/callbacks.py on lines 469..477
                                          tensorflow/python/keras/callbacks.py on lines 479..489

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_test_batch_begin(self, batch, logs=None):
                                              """Calls the `on_test_batch_begin` methods of its callbacks.
                                          
                                              Args:
                                                  batch: Integer, index of batch within the current epoch.
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 50 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 435..445
                                          tensorflow/python/keras/callbacks.py on lines 447..455
                                          tensorflow/python/keras/callbacks.py on lines 469..477
                                          tensorflow/python/keras/callbacks.py on lines 479..489
                                          tensorflow/python/keras/callbacks.py on lines 491..499

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_train_batch_begin(self, batch, logs=None):
                                              """Calls the `on_train_batch_begin` methods of its callbacks.
                                          
                                              Args:
                                                  batch: Integer, index of batch within the current epoch.
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 50 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 447..455
                                          tensorflow/python/keras/callbacks.py on lines 457..467
                                          tensorflow/python/keras/callbacks.py on lines 469..477
                                          tensorflow/python/keras/callbacks.py on lines 479..489
                                          tensorflow/python/keras/callbacks.py on lines 491..499

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_train_batch_end(self, batch, logs=None):
                                              """Calls the `on_train_batch_end` methods of its callbacks.
                                          
                                              Args:
                                                  batch: Integer, index of batch within the current epoch.
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 50 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 435..445
                                          tensorflow/python/keras/callbacks.py on lines 457..467
                                          tensorflow/python/keras/callbacks.py on lines 469..477
                                          tensorflow/python/keras/callbacks.py on lines 479..489
                                          tensorflow/python/keras/callbacks.py on lines 491..499

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_predict_batch_begin(self, batch, logs=None):
                                              """Calls the `on_predict_batch_begin` methods of its callbacks.
                                          
                                              Args:
                                                  batch: Integer, index of batch within the current epoch.
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 50 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 435..445
                                          tensorflow/python/keras/callbacks.py on lines 447..455
                                          tensorflow/python/keras/callbacks.py on lines 457..467
                                          tensorflow/python/keras/callbacks.py on lines 469..477
                                          tensorflow/python/keras/callbacks.py on lines 491..499

                                          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 6 locations. Consider refactoring.
                                          Open

                                            def on_test_batch_end(self, batch, logs=None):
                                              """Calls the `on_test_batch_end` methods of its callbacks.
                                          
                                              Args:
                                                  batch: Integer, index of batch within the current epoch.
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 5 other locations - About 50 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 435..445
                                          tensorflow/python/keras/callbacks.py on lines 447..455
                                          tensorflow/python/keras/callbacks.py on lines 457..467
                                          tensorflow/python/keras/callbacks.py on lines 479..489
                                          tensorflow/python/keras/callbacks.py on lines 491..499

                                          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

                                                avg_end_hook_time = sum(self._hook_times[end_hook_name]) / len(
                                                    self._hook_times[end_hook_name])
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 45 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 343..344

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 35.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

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

                                                avg_begin_hook_time = sum(self._hook_times[begin_hook_name]) / len(
                                                    self._hook_times[begin_hook_name])
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 45 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 341..342

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 35.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

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

                                            def __init__(self):
                                              self.validation_data = None  # pylint: disable=g-missing-from-attributes
                                              self.model = None
                                              # Whether this Callback should only run on the chief worker in a
                                              # Multi-Worker setting.
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 2 other locations - About 40 mins to fix
                                          tensorflow/python/autograph/converters/return_statements.py on lines 157..161
                                          tensorflow/python/distribute/parallel_device/parallel_device_test.py on lines 479..483

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

                                          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.histogram_freq and epoch % self.histogram_freq == 0:
                                                self._log_weights(epoch)
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 40 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 2455..2456

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

                                          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.embeddings_freq and epoch % self.embeddings_freq == 0:
                                                self._log_embeddings(epoch)
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 40 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 2452..2453

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

                                          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 avg_begin_hook_time > threshold_time:
                                                  logging.warning(warning_msg.format(
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 35 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 355..356

                                          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

                                            @doc_controls.for_subclass_implementers
                                            @generic_utils.default
                                            def on_train_batch_begin(self, batch, logs=None):
                                              """Called at the beginning of a training batch in `fit` methods.
                                          
                                          
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 35 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 724..740

                                          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

                                            def on_batch_begin(self, batch, logs=None):
                                              if self._should_call_train_batch_hooks:
                                                self._call_batch_hook(ModeKeys.TRAIN, 'begin', batch, logs=logs)
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 35 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 402..404

                                          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

                                            def on_batch_end(self, batch, logs=None):
                                              if self._should_call_train_batch_hooks:
                                                self._call_batch_hook(ModeKeys.TRAIN, 'end', batch, logs=logs)
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 35 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 398..400

                                          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

                                            @doc_controls.for_subclass_implementers
                                            @generic_utils.default
                                            def on_train_batch_end(self, batch, logs=None):
                                              """Called at the end of a training batch in `fit` methods.
                                          
                                          
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 35 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 704..722

                                          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 avg_end_hook_time > threshold_time:
                                                  logging.warning(warning_msg.format(
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 35 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 350..351

                                          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 4 locations. Consider refactoring.
                                          Open

                                              if on_epoch_begin is not None:
                                                self.on_epoch_begin = on_epoch_begin
                                              else:
                                                self.on_epoch_begin = lambda epoch, logs: None
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 3 other locations - About 30 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 2857..2860
                                          tensorflow/python/keras/callbacks.py on lines 2861..2864
                                          tensorflow/python/keras/callbacks.py on lines 2865..2868

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

                                          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 4 locations. Consider refactoring.
                                          Open

                                              if on_epoch_end is not None:
                                                self.on_epoch_end = on_epoch_end
                                              else:
                                                self.on_epoch_end = lambda epoch, logs: None
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 3 other locations - About 30 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 2853..2856
                                          tensorflow/python/keras/callbacks.py on lines 2861..2864
                                          tensorflow/python/keras/callbacks.py on lines 2865..2868

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

                                          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 4 locations. Consider refactoring.
                                          Open

                                              if on_batch_end is not None:
                                                self.on_batch_end = on_batch_end
                                              else:
                                                self.on_batch_end = lambda batch, logs: None
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 3 other locations - About 30 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 2853..2856
                                          tensorflow/python/keras/callbacks.py on lines 2857..2860
                                          tensorflow/python/keras/callbacks.py on lines 2861..2864

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

                                          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 len(shape) == 4 and shape[-1] in [1, 3, 4]:
                                          Severity: Minor
                                          Found in tensorflow/python/keras/callbacks.py and 1 other location - About 30 mins to fix
                                          tensorflow/python/keras/callbacks_v1.py on lines 207..207

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

                                          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 4 locations. Consider refactoring.
                                          Open

                                              if on_batch_begin is not None:
                                                self.on_batch_begin = on_batch_begin
                                              else:
                                                self.on_batch_begin = lambda batch, logs: None
                                          Severity: Major
                                          Found in tensorflow/python/keras/callbacks.py and 3 other locations - About 30 mins to fix
                                          tensorflow/python/keras/callbacks.py on lines 2853..2856
                                          tensorflow/python/keras/callbacks.py on lines 2857..2860
                                          tensorflow/python/keras/callbacks.py on lines 2865..2868

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

                                          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