The following issues were found

keras/premade/wide_deep.py
97 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Built-in WideNDeep model classes."""

import tensorflow.compat.v2 as tf
from keras import activations
from keras import backend
from keras import layers as layer_module
from keras.engine import base_layer
from keras.engine import data_adapter

            

Reported by Pylint.

Unable to import 'tensorflow.python.util'
Error

Line: 25 Column: 1

              from keras.engine import data_adapter
from keras.engine import training as keras_training
from keras.utils import generic_utils
from tensorflow.python.util import deprecation  # pylint: disable=g-direct-tensorflow-import
from tensorflow.python.util.tf_export import keras_export


@keras_export(
    'keras.experimental.WideDeepModel',

            

Reported by Pylint.

Bad option value 'g-direct-tensorflow-import'
Error

Line: 25 Column: 1

              from keras.engine import data_adapter
from keras.engine import training as keras_training
from keras.utils import generic_utils
from tensorflow.python.util import deprecation  # pylint: disable=g-direct-tensorflow-import
from tensorflow.python.util.tf_export import keras_export


@keras_export(
    'keras.experimental.WideDeepModel',

            

Reported by Pylint.

Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 26 Column: 1

              from keras.engine import training as keras_training
from keras.utils import generic_utils
from tensorflow.python.util import deprecation  # pylint: disable=g-direct-tensorflow-import
from tensorflow.python.util.tf_export import keras_export


@keras_export(
    'keras.experimental.WideDeepModel',
    v1=['keras.experimental.WideDeepModel', 'keras.models.WideDeepModel'])

            

Reported by Pylint.

Parameters differ from overridden 'call' method
Error

Line: 92 Column: 3

                  self.dnn_model = dnn_model
    self.activation = activations.get(activation)

  def call(self, inputs, training=None):
    if not isinstance(inputs, (tuple, list)) or len(inputs) != 2:
      linear_inputs = dnn_inputs = inputs
    else:
      linear_inputs, dnn_inputs = inputs
    linear_output = self.linear_model(linear_inputs)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 34 Column: 1

                  v1=['keras.experimental.WideDeepModel', 'keras.models.WideDeepModel'])
@deprecation.deprecated_endpoints('keras.experimental.WideDeepModel')
class WideDeepModel(keras_training.Model):
  r"""Wide & Deep Model for regression and classification problems.

  This model jointly train a linear and a dnn model.

  Example:


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 73 Column: 1

              
  """

  def __init__(self, linear_model, dnn_model, activation=None, **kwargs):
    """Create a Wide & Deep Model.

    Args:
      linear_model: a premade LinearModel, its output must match the output of
        the dnn model.

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 74 Column: 1

                """

  def __init__(self, linear_model, dnn_model, activation=None, **kwargs):
    """Create a Wide & Deep Model.

    Args:
      linear_model: a premade LinearModel, its output must match the output of
        the dnn model.
      dnn_model: a `tf.keras.Model`, its output must match the output of the

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 86 Column: 1

                    **kwargs: The keyword arguments that are passed on to BaseLayer.__init__.
        Allowed keyword arguments include `name`.
    """
    super(WideDeepModel, self).__init__(**kwargs)
    base_layer.keras_premade_model_gauge.get_cell('WideDeep').set(True)
    self.linear_model = linear_model
    self.dnn_model = dnn_model
    self.activation = activations.get(activation)


            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 86 Column: 5

                    **kwargs: The keyword arguments that are passed on to BaseLayer.__init__.
        Allowed keyword arguments include `name`.
    """
    super(WideDeepModel, self).__init__(**kwargs)
    base_layer.keras_premade_model_gauge.get_cell('WideDeep').set(True)
    self.linear_model = linear_model
    self.dnn_model = dnn_model
    self.activation = activations.get(activation)


            

Reported by Pylint.

keras/saving/saved_model/layer_serialization.py
97 issues
Unable to import 'keras.mixed_precision'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Classes and functions implementing Layer SavedModel serialization."""

from keras.mixed_precision import policy
from keras.saving.saved_model import base_serialization
from keras.saving.saved_model import constants
from keras.saving.saved_model import save_impl
from keras.saving.saved_model import serialized_attributes
from keras.utils import generic_utils

            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 18 Column: 1

              """Classes and functions implementing Layer SavedModel serialization."""

from keras.mixed_precision import policy
from keras.saving.saved_model import base_serialization
from keras.saving.saved_model import constants
from keras.saving.saved_model import save_impl
from keras.saving.saved_model import serialized_attributes
from keras.utils import generic_utils
import tensorflow.compat.v2 as tf

            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 19 Column: 1

              
from keras.mixed_precision import policy
from keras.saving.saved_model import base_serialization
from keras.saving.saved_model import constants
from keras.saving.saved_model import save_impl
from keras.saving.saved_model import serialized_attributes
from keras.utils import generic_utils
import tensorflow.compat.v2 as tf


            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 20 Column: 1

              from keras.mixed_precision import policy
from keras.saving.saved_model import base_serialization
from keras.saving.saved_model import constants
from keras.saving.saved_model import save_impl
from keras.saving.saved_model import serialized_attributes
from keras.utils import generic_utils
import tensorflow.compat.v2 as tf



            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 21 Column: 1

              from keras.saving.saved_model import base_serialization
from keras.saving.saved_model import constants
from keras.saving.saved_model import save_impl
from keras.saving.saved_model import serialized_attributes
from keras.utils import generic_utils
import tensorflow.compat.v2 as tf


class LayerSavedModelSaver(base_serialization.SavedModelSaver):

            

Reported by Pylint.

Unable to import 'keras.utils'
Error

Line: 22 Column: 1

              from keras.saving.saved_model import constants
from keras.saving.saved_model import save_impl
from keras.saving.saved_model import serialized_attributes
from keras.utils import generic_utils
import tensorflow.compat.v2 as tf


class LayerSavedModelSaver(base_serialization.SavedModelSaver):
  """Implements Layer SavedModel serialization."""

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 23 Column: 1

              from keras.saving.saved_model import save_impl
from keras.saving.saved_model import serialized_attributes
from keras.utils import generic_utils
import tensorflow.compat.v2 as tf


class LayerSavedModelSaver(base_serialization.SavedModelSaver):
  """Implements Layer SavedModel serialization."""


            

Reported by Pylint.

TODO(kathywu): Add python property validator
Error

Line: 35 Column: 3

              
  @property
  def python_properties(self):
    # TODO(kathywu): Add python property validator
    return self._python_properties_internal()

  def _python_properties_internal(self):
    """Returns dictionary of all python properties."""
    # TODO(kathywu): Add support for metrics serialization.

            

Reported by Pylint.

TODO(kathywu): Add support for metrics serialization.
Error

Line: 40 Column: 3

              
  def _python_properties_internal(self):
    """Returns dictionary of all python properties."""
    # TODO(kathywu): Add support for metrics serialization.
    # TODO(kathywu): Synchronize with the keras spec (go/keras-json-spec) once
    # the python config serialization has caught up.
    metadata = dict(
        name=self.obj.name,
        trainable=self.obj.trainable,

            

Reported by Pylint.

TODO(kathywu): Synchronize with the keras spec (go/keras-json-spec) once
Error

Line: 41 Column: 3

                def _python_properties_internal(self):
    """Returns dictionary of all python properties."""
    # TODO(kathywu): Add support for metrics serialization.
    # TODO(kathywu): Synchronize with the keras spec (go/keras-json-spec) once
    # the python config serialization has caught up.
    metadata = dict(
        name=self.obj.name,
        trainable=self.obj.trainable,
        expects_training_arg=self.obj._expects_training_arg,  # pylint: disable=protected-access

            

Reported by Pylint.

keras/saving/saved_model/serialized_attributes.py
96 issues
Unable to import 'keras.saving.saved_model'
Error

Line: 18 Column: 1

              """Helper classes that list&validate all attributes to serialize to SavedModel.
"""

from keras.saving.saved_model import constants
from keras.saving.saved_model import order_preserving_set as ops
from keras.saving.saved_model import save_impl
from keras.utils.generic_utils import LazyLoader
import tensorflow.compat.v2 as tf


            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 19 Column: 1

              """

from keras.saving.saved_model import constants
from keras.saving.saved_model import order_preserving_set as ops
from keras.saving.saved_model import save_impl
from keras.utils.generic_utils import LazyLoader
import tensorflow.compat.v2 as tf

# TODO(b/134426265): Switch back to single-quotes to match the rest of the file

            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 20 Column: 1

              
from keras.saving.saved_model import constants
from keras.saving.saved_model import order_preserving_set as ops
from keras.saving.saved_model import save_impl
from keras.utils.generic_utils import LazyLoader
import tensorflow.compat.v2 as tf

# TODO(b/134426265): Switch back to single-quotes to match the rest of the file
# once the issue with copybara is fixed.

            

Reported by Pylint.

Unable to import 'keras.utils.generic_utils'
Error

Line: 21 Column: 1

              from keras.saving.saved_model import constants
from keras.saving.saved_model import order_preserving_set as ops
from keras.saving.saved_model import save_impl
from keras.utils.generic_utils import LazyLoader
import tensorflow.compat.v2 as tf

# TODO(b/134426265): Switch back to single-quotes to match the rest of the file
# once the issue with copybara is fixed.
# pylint:disable=g-inconsistent-quotes

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 22 Column: 1

              from keras.saving.saved_model import order_preserving_set as ops
from keras.saving.saved_model import save_impl
from keras.utils.generic_utils import LazyLoader
import tensorflow.compat.v2 as tf

# TODO(b/134426265): Switch back to single-quotes to match the rest of the file
# once the issue with copybara is fixed.
# pylint:disable=g-inconsistent-quotes
base_layer = LazyLoader(

            

Reported by Pylint.

Bad option value 'g-inconsistent-quotes'
Error

Line: 26 Column: 1

              
# TODO(b/134426265): Switch back to single-quotes to match the rest of the file
# once the issue with copybara is fixed.
# pylint:disable=g-inconsistent-quotes
base_layer = LazyLoader(
    "base_layer", globals(),
    "keras.engine.base_layer")
training_lib = LazyLoader(
    "training_lib", globals(),

            

Reported by Pylint.

Bad option value 'g-inconsistent-quotes'
Error

Line: 38 Column: 1

              recurrent = LazyLoader(
    "recurrent", globals(),
    "keras.layers.recurrent")
# pylint:enable=g-inconsistent-quotes


class SerializedAttributes:
  """Class that tracks and validates all serialization attributes.


            

Reported by Pylint.

Instance of 'SerializedAttributes' has no 'all_functions' member
Error

Line: 196 Column: 16

              
  def set_and_validate_functions(self, function_dict):
    """Saves function dictionary, and validates dictionary values."""
    for key in self.all_functions:
      if key in function_dict:
        if (function_dict[key] is not None and  # Not all functions are required
            not isinstance(function_dict[key],
                           (tf.__internal__.function.Function,
                            tf.types.experimental.ConcreteFunction,

            

Reported by Pylint.

Instance of 'SerializedAttributes' has no 'all_checkpointable_objects' member
Error

Line: 220 Column: 16

              
  def set_and_validate_objects(self, object_dict):
    """Saves objects to a dictionary, and validates the values."""
    for key in self.all_checkpointable_objects:
      if key in object_dict:
        if not isinstance(object_dict[key], tf.__internal__.tracking.Trackable):
          raise ValueError(
              'The object dictionary contained a non-trackable object: '
              f'{object_dict[key]} (for key {key}). Only trackable objects are '

            

Reported by Pylint.

TODO(b/134426265): Switch back to single-quotes to match the rest of the file
Error

Line: 24 Column: 3

              from keras.utils.generic_utils import LazyLoader
import tensorflow.compat.v2 as tf

# TODO(b/134426265): Switch back to single-quotes to match the rest of the file
# once the issue with copybara is fixed.
# pylint:disable=g-inconsistent-quotes
base_layer = LazyLoader(
    "base_layer", globals(),
    "keras.engine.base_layer")

            

Reported by Pylint.

keras/benchmarks/benchmark_util.py
95 issues
Unable to import 'tensorflow'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Common utils for benchmarks."""

import tensorflow as tf

import timeit
import numpy as np

from keras.benchmarks import distribution_util

            

Reported by Pylint.

Unused argument 'e'
Error

Line: 83 Column: 28

                  self.startup_time = timeit.default_timer()
    self.recorded_startup = False

  def on_epoch_begin(self, e, logs):
    self.epoch_start_time = self.timer()

  def on_epoch_end(self, e, logs):
    self.times.append(self.timer() - self.epoch_start_time)


            

Reported by Pylint.

Unused argument 'logs'
Error

Line: 83 Column: 31

                  self.startup_time = timeit.default_timer()
    self.recorded_startup = False

  def on_epoch_begin(self, e, logs):
    self.epoch_start_time = self.timer()

  def on_epoch_end(self, e, logs):
    self.times.append(self.timer() - self.epoch_start_time)


            

Reported by Pylint.

Attribute 'epoch_start_time' defined outside __init__
Error

Line: 84 Column: 5

                  self.recorded_startup = False

  def on_epoch_begin(self, e, logs):
    self.epoch_start_time = self.timer()

  def on_epoch_end(self, e, logs):
    self.times.append(self.timer() - self.epoch_start_time)

  def on_batch_end(self, e, logs):

            

Reported by Pylint.

Unused argument 'e'
Error

Line: 86 Column: 26

                def on_epoch_begin(self, e, logs):
    self.epoch_start_time = self.timer()

  def on_epoch_end(self, e, logs):
    self.times.append(self.timer() - self.epoch_start_time)

  def on_batch_end(self, e, logs):
    if not self.recorded_startup:
      self.startup_time = self.timer() - self.startup_time

            

Reported by Pylint.

Unused argument 'logs'
Error

Line: 86 Column: 29

                def on_epoch_begin(self, e, logs):
    self.epoch_start_time = self.timer()

  def on_epoch_end(self, e, logs):
    self.times.append(self.timer() - self.epoch_start_time)

  def on_batch_end(self, e, logs):
    if not self.recorded_startup:
      self.startup_time = self.timer() - self.startup_time

            

Reported by Pylint.

Unused argument 'e'
Error

Line: 89 Column: 26

                def on_epoch_end(self, e, logs):
    self.times.append(self.timer() - self.epoch_start_time)

  def on_batch_end(self, e, logs):
    if not self.recorded_startup:
      self.startup_time = self.timer() - self.startup_time
      self.recorded_startup = True



            

Reported by Pylint.

Unused argument 'logs'
Error

Line: 89 Column: 29

                def on_epoch_end(self, e, logs):
    self.times.append(self.timer() - self.epoch_start_time)

  def on_batch_end(self, e, logs):
    if not self.recorded_startup:
      self.startup_time = self.timer() - self.startup_time
      self.recorded_startup = True



            

Reported by Pylint.

TODO(xingyulong): we will add tfds support later and
Error

Line: 151 Column: 3

                if num_gpus < 0:
    raise ValueError('`num_gpus` cannot be negative')

  # TODO(xingyulong): we will add tfds support later and
  #  get the `num_examples` from info.
  num_examples = x.shape[0]

  build_time_list, compile_time_list, startup_time_list = [], [], []
  avg_epoch_time_list, wall_time_list, exp_per_sec_list = [], [], []

            

Reported by Pylint.

standard import "import timeit" should be placed before "import tensorflow as tf"
Error

Line: 19 Column: 1

              
import tensorflow as tf

import timeit
import numpy as np

from keras.benchmarks import distribution_util



            

Reported by Pylint.

keras/constraints.py
94 issues
Bad option value 'g-classes-have-attributes'
Error

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================
# pylint: disable=invalid-name
# pylint: disable=g-classes-have-attributes
"""Constraints: functions that impose constraints on weight values."""

import tensorflow.compat.v2 as tf
from keras import backend
from keras.utils.generic_utils import deserialize_keras_object

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 19 Column: 1

              # pylint: disable=g-classes-have-attributes
"""Constraints: functions that impose constraints on weight values."""

import tensorflow.compat.v2 as tf
from keras import backend
from keras.utils.generic_utils import deserialize_keras_object
from keras.utils.generic_utils import serialize_keras_object
from tensorflow.python.util.tf_export import keras_export
from tensorflow.tools.docs import doc_controls

            

Reported by Pylint.

Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 23 Column: 1

              from keras import backend
from keras.utils.generic_utils import deserialize_keras_object
from keras.utils.generic_utils import serialize_keras_object
from tensorflow.python.util.tf_export import keras_export
from tensorflow.tools.docs import doc_controls


@keras_export('keras.constraints.Constraint')
class Constraint:

            

Reported by Pylint.

Unable to import 'tensorflow.tools.docs'
Error

Line: 24 Column: 1

              from keras.utils.generic_utils import deserialize_keras_object
from keras.utils.generic_utils import serialize_keras_object
from tensorflow.python.util.tf_export import keras_export
from tensorflow.tools.docs import doc_controls


@keras_export('keras.constraints.Constraint')
class Constraint:
  """Base class for weight constraints.

            

Reported by Pylint.

Bad option value 'g-long-lambda'
Error

Line: 283 Column: 1

                  kernel_new = backend.switch(
        backend.cast(tf.math.floormod(kernel_shape, 2), 'bool'),
        lambda: kernel[start - 1:start, start - 1:start],
        lambda: kernel[start - 1:start, start - 1:start] + backend.zeros(  # pylint: disable=g-long-lambda
            (2, 2), dtype=kernel.dtype))
    index = backend.switch(
        backend.cast(tf.math.floormod(kernel_shape, 2), 'bool'),
        lambda: backend.constant(0, dtype='int32'),
        lambda: backend.constant(1, dtype='int32'))

            

Reported by Pylint.

TODO(cpeter): Switch map_fn for a faster tf.vectorized_map once
Error

Line: 265 Column: 3

              
    height, width, channels, kernels = w_shape
    w = backend.reshape(w, (height, width, channels * kernels))
    # TODO(cpeter): Switch map_fn for a faster tf.vectorized_map once
    # backend.switch is supported.
    w = backend.map_fn(
        self._kernel_constraint,
        backend.stack(tf.unstack(w, axis=-1), axis=0))
    return backend.reshape(backend.stack(tf.unstack(w, axis=0), axis=-1),

            

Reported by Pylint.

third party import "from tensorflow.python.util.tf_export import keras_export" should be placed before "from keras import backend"
Error

Line: 23 Column: 1

              from keras import backend
from keras.utils.generic_utils import deserialize_keras_object
from keras.utils.generic_utils import serialize_keras_object
from tensorflow.python.util.tf_export import keras_export
from tensorflow.tools.docs import doc_controls


@keras_export('keras.constraints.Constraint')
class Constraint:

            

Reported by Pylint.

third party import "from tensorflow.tools.docs import doc_controls" should be placed before "from keras import backend"
Error

Line: 24 Column: 1

              from keras.utils.generic_utils import deserialize_keras_object
from keras.utils.generic_utils import serialize_keras_object
from tensorflow.python.util.tf_export import keras_export
from tensorflow.tools.docs import doc_controls


@keras_export('keras.constraints.Constraint')
class Constraint:
  """Base class for weight constraints.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 29 Column: 1

              
@keras_export('keras.constraints.Constraint')
class Constraint:
  """Base class for weight constraints.

  A `Constraint` instance works like a stateless function.
  Users who subclass this
  class should override the `__call__` method, which takes a single
  weight parameter and return a projected version of that parameter

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 52 Column: 1

                >>> tf.keras.layers.Dense(4, kernel_constraint=NonNegative())
  """

  def __call__(self, w):
    """Applies the constraint to the input weight variable.

    By default, the inputs weight variable is not modified.
    Users should override this method to implement their own projection
    function.

            

Reported by Pylint.

keras/utils/traceback_utils.py
93 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 22 Column: 1

              import sys
import traceback
import types
import tensorflow.compat.v2 as tf


_EXCLUDED_PATHS = (
    os.path.abspath(os.path.join(__file__, '..', '..')),
    os.path.join('tensorflow', 'python'),

            

Reported by Pylint.

Instance of 'Exception' has no 'message' member
Error

Line: 119 Column: 21

                      arguments_context = '\n'.join(arguments_context)
        # Get original error message and append information to it.
        if isinstance(e, tf.errors.OpError):
          message = e.message
        elif e.args:
          # Canonically, the 1st argument in an exception is the error message.
          # This works for all built-in Python exceptions.
          message = e.args[0]
        else:

            

Reported by Pylint.

Instance of 'Exception' has no 'error_code' member
Error

Line: 134 Column: 58

              
        # Reraise exception, with added context
        if isinstance(e, tf.errors.OpError):
          new_e = e.__class__(e.node_def, e.op, message, e.error_code)
        else:
          try:
            # For standard exceptions such as ValueError, TypeError, etc.
            new_e = e.__class__(message)
          except TypeError:

            

Reported by Pylint.

Instance of 'Exception' has no 'node_def' member
Error

Line: 134 Column: 31

              
        # Reraise exception, with added context
        if isinstance(e, tf.errors.OpError):
          new_e = e.__class__(e.node_def, e.op, message, e.error_code)
        else:
          try:
            # For standard exceptions such as ValueError, TypeError, etc.
            new_e = e.__class__(message)
          except TypeError:

            

Reported by Pylint.

Instance of 'Exception' has no 'op' member
Error

Line: 134 Column: 43

              
        # Reraise exception, with added context
        if isinstance(e, tf.errors.OpError):
          new_e = e.__class__(e.node_def, e.op, message, e.error_code)
        else:
          try:
            # For standard exceptions such as ValueError, TypeError, etc.
            new_e = e.__class__(message)
          except TypeError:

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 103 Column: 9

                      bound_signature = signature.bind(*args, **kwargs)
      except TypeError:
        # Likely unbindable arguments
        raise e

      # Add argument context
      arguments_context = []
      for arg in list(signature.parameters.values()):
        if arg.name in bound_signature.arguments:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 1

              )


def include_frame(fname):
  for exclusion in _EXCLUDED_PATHS:
    if exclusion in fname:
      return False
  return True


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              

def include_frame(fname):
  for exclusion in _EXCLUDED_PATHS:
    if exclusion in fname:
      return False
  return True



            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 33 Column: 1

              
def include_frame(fname):
  for exclusion in _EXCLUDED_PATHS:
    if exclusion in fname:
      return False
  return True


def _process_traceback_frames(tb):

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 34 Column: 1

              def include_frame(fname):
  for exclusion in _EXCLUDED_PATHS:
    if exclusion in fname:
      return False
  return True


def _process_traceback_frames(tb):
  """Iterate through traceback frames and return a new, filtered traceback."""

            

Reported by Pylint.

keras/optimizer_v2/legacy_learning_rate_decay.py
92 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Various learning rate decay functions."""

import tensorflow.compat.v2 as tf

import functools
from keras.optimizer_v2 import learning_rate_schedule
from tensorflow.python.util.tf_export import tf_export


            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf

import functools
from keras.optimizer_v2 import learning_rate_schedule
from tensorflow.python.util.tf_export import tf_export


@tf_export(v1=["train.exponential_decay"])
def exponential_decay(learning_rate,

            

Reported by Pylint.

Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 21 Column: 1

              
import functools
from keras.optimizer_v2 import learning_rate_schedule
from tensorflow.python.util.tf_export import tf_export


@tf_export(v1=["train.exponential_decay"])
def exponential_decay(learning_rate,
                      global_step,

            

Reported by Pylint.

standard import "import functools" should be placed before "import tensorflow.compat.v2 as tf"
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

import functools
from keras.optimizer_v2 import learning_rate_schedule
from tensorflow.python.util.tf_export import tf_export


@tf_export(v1=["train.exponential_decay"])

            

Reported by Pylint.

Too many arguments (6/5)
Error

Line: 25 Column: 1

              

@tf_export(v1=["train.exponential_decay"])
def exponential_decay(learning_rate,
                      global_step,
                      decay_steps,
                      decay_rate,
                      staircase=False,
                      name=None):

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 31 Column: 1

                                    decay_rate,
                      staircase=False,
                      name=None):
  """Applies exponential decay to the learning rate.

  When training a model, it is often recommended to lower the learning rate as
  the training progresses.  This function applies an exponential decay function
  to a provided initial learning rate.  It requires a `global_step` value to
  compute the decayed learning rate.  You can just pass a TensorFlow variable

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 91 Column: 1

                the learning rate value across different invocations of optimizer functions.
  @end_compatibility
  """
  decayed_lr = learning_rate_schedule.ExponentialDecay(
      learning_rate, decay_steps, decay_rate, staircase=staircase, name=name)
  if not tf.executing_eagerly():
    decayed_lr = decayed_lr(global_step)
  else:
    decayed_lr = functools.partial(decayed_lr, global_step)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 93 Column: 1

                """
  decayed_lr = learning_rate_schedule.ExponentialDecay(
      learning_rate, decay_steps, decay_rate, staircase=staircase, name=name)
  if not tf.executing_eagerly():
    decayed_lr = decayed_lr(global_step)
  else:
    decayed_lr = functools.partial(decayed_lr, global_step)
  return decayed_lr


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 94 Column: 1

                decayed_lr = learning_rate_schedule.ExponentialDecay(
      learning_rate, decay_steps, decay_rate, staircase=staircase, name=name)
  if not tf.executing_eagerly():
    decayed_lr = decayed_lr(global_step)
  else:
    decayed_lr = functools.partial(decayed_lr, global_step)
  return decayed_lr



            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 95 Column: 1

                    learning_rate, decay_steps, decay_rate, staircase=staircase, name=name)
  if not tf.executing_eagerly():
    decayed_lr = decayed_lr(global_step)
  else:
    decayed_lr = functools.partial(decayed_lr, global_step)
  return decayed_lr


@tf_export(v1=["train.piecewise_constant_decay", "train.piecewise_constant"])

            

Reported by Pylint.

keras/preprocessing/text_test.py
92 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 18 Column: 1

              # ==============================================================================
"""Tests for text data preprocessing utils."""

import tensorflow.compat.v2 as tf

import numpy as np

from keras.preprocessing import text as preprocessing_text


            

Reported by Pylint.

Missing class docstring
Error

Line: 25 Column: 1

              from keras.preprocessing import text as preprocessing_text


class TestText(tf.test.TestCase):

  def test_one_hot(self):
    text = 'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 27 Column: 1

              
class TestText(tf.test.TestCase):

  def test_one_hot(self):
    text = 'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)
    self.assertLessEqual(np.max(encoded), 4)
    self.assertGreaterEqual(np.min(encoded), 0)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 3

              
class TestText(tf.test.TestCase):

  def test_one_hot(self):
    text = 'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)
    self.assertLessEqual(np.max(encoded), 4)
    self.assertGreaterEqual(np.min(encoded), 0)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 28 Column: 1

              class TestText(tf.test.TestCase):

  def test_one_hot(self):
    text = 'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)
    self.assertLessEqual(np.max(encoded), 4)
    self.assertGreaterEqual(np.min(encoded), 0)


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 29 Column: 1

              
  def test_one_hot(self):
    text = 'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)
    self.assertLessEqual(np.max(encoded), 4)
    self.assertGreaterEqual(np.min(encoded), 0)

    # Test on unicode.

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 30 Column: 1

                def test_one_hot(self):
    text = 'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)
    self.assertLessEqual(np.max(encoded), 4)
    self.assertGreaterEqual(np.min(encoded), 0)

    # Test on unicode.
    text = u'The cat sat on the mat.'

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 31 Column: 1

                  text = 'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)
    self.assertLessEqual(np.max(encoded), 4)
    self.assertGreaterEqual(np.min(encoded), 0)

    # Test on unicode.
    text = u'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 32 Column: 1

                  encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)
    self.assertLessEqual(np.max(encoded), 4)
    self.assertGreaterEqual(np.min(encoded), 0)

    # Test on unicode.
    text = u'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 35 Column: 1

                  self.assertGreaterEqual(np.min(encoded), 0)

    # Test on unicode.
    text = u'The cat sat on the mat.'
    encoded = preprocessing_text.one_hot(text, 5)
    self.assertEqual(len(encoded), 6)
    self.assertLessEqual(np.max(encoded), 4)
    self.assertGreaterEqual(np.min(encoded), 0)


            

Reported by Pylint.

keras/distribute/saved_model_save_load_test.py
91 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for saving and loading using tf's saved_model APIs with DS."""

import tensorflow.compat.v2 as tf

import os
from keras import testing_utils
from keras.distribute import model_combinations
from keras.distribute import saved_model_test_base as test_base

            

Reported by Pylint.

Access to a protected member _DEFAULT_FUNCTION_KEY of a client class
Error

Line: 79 Column: 41

                  saved_dir = self.run_test_save_strategy(model_and_input, distribution,
                                            save_in_scope)
    func = tf.saved_model.load(saved_dir)
    concrete_function = func.signatures[test_base._DEFAULT_FUNCTION_KEY]
    for f in concrete_function.graph.as_graph_def().library.function:
      for n in f.node_def:
        if n.op == 'ReadVariableOp':
          self.assertEmpty(n.device)


            

Reported by Pylint.

standard import "import os" should be placed before "import tensorflow.compat.v2 as tf"
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

import os
from keras import testing_utils
from keras.distribute import model_combinations
from keras.distribute import saved_model_test_base as test_base



            

Reported by Pylint.

Missing class docstring
Error

Line: 27 Column: 1

              
@testing_utils.run_all_without_tensor_float_32(
    'Uses Dense layers, which call matmul')
class SavedModelKerasModelTest(test_base.TestSavedModelBase):

  def setUp(self):
    self._root_dir = 'saved_model_save_load'
    super(SavedModelKerasModelTest, self).setUp()


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 29 Column: 1

                  'Uses Dense layers, which call matmul')
class SavedModelKerasModelTest(test_base.TestSavedModelBase):

  def setUp(self):
    self._root_dir = 'saved_model_save_load'
    super(SavedModelKerasModelTest, self).setUp()

  def _save_model(self, model, saved_dir):
    tf.saved_model.save(model, saved_dir)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 30 Column: 1

              class SavedModelKerasModelTest(test_base.TestSavedModelBase):

  def setUp(self):
    self._root_dir = 'saved_model_save_load'
    super(SavedModelKerasModelTest, self).setUp()

  def _save_model(self, model, saved_dir):
    tf.saved_model.save(model, saved_dir)


            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 31 Column: 5

              
  def setUp(self):
    self._root_dir = 'saved_model_save_load'
    super(SavedModelKerasModelTest, self).setUp()

  def _save_model(self, model, saved_dir):
    tf.saved_model.save(model, saved_dir)

  def _load_and_run_model(self,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 31 Column: 1

              
  def setUp(self):
    self._root_dir = 'saved_model_save_load'
    super(SavedModelKerasModelTest, self).setUp()

  def _save_model(self, model, saved_dir):
    tf.saved_model.save(model, saved_dir)

  def _load_and_run_model(self,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 33 Column: 1

                  self._root_dir = 'saved_model_save_load'
    super(SavedModelKerasModelTest, self).setUp()

  def _save_model(self, model, saved_dir):
    tf.saved_model.save(model, saved_dir)

  def _load_and_run_model(self,
                          distribution,
                          saved_dir,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 34 Column: 1

                  super(SavedModelKerasModelTest, self).setUp()

  def _save_model(self, model, saved_dir):
    tf.saved_model.save(model, saved_dir)

  def _load_and_run_model(self,
                          distribution,
                          saved_dir,
                          predict_dataset,

            

Reported by Pylint.

keras/layers/preprocessing/benchmarks/image_preproc_benchmark.py
91 issues
Unable to import 'tensorflow'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Benchmark for Keras image preprocessing layer."""

import tensorflow as tf

import functools
import time

import numpy as np

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 24 Column: 1

              
import numpy as np

import keras
from keras.layers.preprocessing import image_preprocessing

tf.compat.v1.enable_v2_behavior()

LOWER = .2

            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing'
Error

Line: 25 Column: 1

              import numpy as np

import keras
from keras.layers.preprocessing import image_preprocessing

tf.compat.v1.enable_v2_behavior()

LOWER = .2
UPPER = .4

            

Reported by Pylint.

standard import "import functools" should be placed before "import tensorflow as tf"
Error

Line: 19 Column: 1

              
import tensorflow as tf

import functools
import time

import numpy as np

import keras

            

Reported by Pylint.

standard import "import time" should be placed before "import tensorflow as tf"
Error

Line: 20 Column: 1

              import tensorflow as tf

import functools
import time

import numpy as np

import keras
from keras.layers.preprocessing import image_preprocessing

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 35 Column: 1

              

def rotate(inputs):
  """rotate image."""
  inputs_shape = tf.shape(inputs)
  batch_size = inputs_shape[0]
  img_hd = tf.cast(inputs_shape[1], tf.float32)
  img_wd = tf.cast(inputs_shape[2], tf.float32)
  min_angle = LOWER * 2. * np.pi

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 36 Column: 1

              
def rotate(inputs):
  """rotate image."""
  inputs_shape = tf.shape(inputs)
  batch_size = inputs_shape[0]
  img_hd = tf.cast(inputs_shape[1], tf.float32)
  img_wd = tf.cast(inputs_shape[2], tf.float32)
  min_angle = LOWER * 2. * np.pi
  max_angle = UPPER * 2. * np.pi

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 37 Column: 1

              def rotate(inputs):
  """rotate image."""
  inputs_shape = tf.shape(inputs)
  batch_size = inputs_shape[0]
  img_hd = tf.cast(inputs_shape[1], tf.float32)
  img_wd = tf.cast(inputs_shape[2], tf.float32)
  min_angle = LOWER * 2. * np.pi
  max_angle = UPPER * 2. * np.pi
  angles = tf.random.uniform(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 38 Column: 1

                """rotate image."""
  inputs_shape = tf.shape(inputs)
  batch_size = inputs_shape[0]
  img_hd = tf.cast(inputs_shape[1], tf.float32)
  img_wd = tf.cast(inputs_shape[2], tf.float32)
  min_angle = LOWER * 2. * np.pi
  max_angle = UPPER * 2. * np.pi
  angles = tf.random.uniform(
      shape=[batch_size], minval=min_angle, maxval=max_angle)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 39 Column: 1

                inputs_shape = tf.shape(inputs)
  batch_size = inputs_shape[0]
  img_hd = tf.cast(inputs_shape[1], tf.float32)
  img_wd = tf.cast(inputs_shape[2], tf.float32)
  min_angle = LOWER * 2. * np.pi
  max_angle = UPPER * 2. * np.pi
  angles = tf.random.uniform(
      shape=[batch_size], minval=min_angle, maxval=max_angle)
  return image_preprocessing.transform(

            

Reported by Pylint.