The following issues were found

keras/applications/vgg19.py
68 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 23 Column: 1

                    https://arxiv.org/abs/1409.1556) (ICLR 2015)
"""

import tensorflow.compat.v2 as tf

from keras import backend
from keras.applications import imagenet_utils
from keras.engine import training
from keras.layers import VersionAwareLayers

            

Reported by Pylint.

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

Line: 31 Column: 1

              from keras.layers import VersionAwareLayers
from keras.utils import data_utils
from keras.utils import layer_utils
from tensorflow.python.util.tf_export import keras_export


WEIGHTS_PATH = ('https://storage.googleapis.com/tensorflow/keras-applications/'
                'vgg19/vgg19_weights_tf_dim_ordering_tf_kernels.h5')
WEIGHTS_PATH_NO_TOP = ('https://storage.googleapis.com/tensorflow/'

            

Reported by Pylint.

Too many statements (56/50)
Error

Line: 44 Column: 1

              

@keras_export('keras.applications.vgg19.VGG19', 'keras.applications.VGG19')
def VGG19(
    include_top=True,
    weights='imagenet',
    input_tensor=None,
    input_shape=None,
    pooling=None,

            

Reported by Pylint.

Too many arguments (7/5)
Error

Line: 44 Column: 1

              

@keras_export('keras.applications.vgg19.VGG19', 'keras.applications.VGG19')
def VGG19(
    include_top=True,
    weights='imagenet',
    input_tensor=None,
    input_shape=None,
    pooling=None,

            

Reported by Pylint.

Too many branches (14/12)
Error

Line: 44 Column: 1

              

@keras_export('keras.applications.vgg19.VGG19', 'keras.applications.VGG19')
def VGG19(
    include_top=True,
    weights='imagenet',
    input_tensor=None,
    input_shape=None,
    pooling=None,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 52 Column: 1

                  pooling=None,
    classes=1000,
    classifier_activation='softmax'):
  """Instantiates the VGG19 architecture.

  Reference:
  - [Very Deep Convolutional Networks for Large-Scale Image Recognition](
      https://arxiv.org/abs/1409.1556) (ICLR 2015)


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 115 Column: 1

                Returns:
    A `keras.Model` instance.
  """
  if not (weights in {'imagenet', None} or tf.io.gfile.exists(weights)):
    raise ValueError('The `weights` argument should be either '
                     '`None` (random initialization), `imagenet` '
                     '(pre-training on ImageNet), '
                     'or the path to the weights file to be loaded.  '
                     f'Received: `weights={weights}.`')

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 116 Column: 1

                  A `keras.Model` instance.
  """
  if not (weights in {'imagenet', None} or tf.io.gfile.exists(weights)):
    raise ValueError('The `weights` argument should be either '
                     '`None` (random initialization), `imagenet` '
                     '(pre-training on ImageNet), '
                     'or the path to the weights file to be loaded.  '
                     f'Received: `weights={weights}.`')


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 122 Column: 1

                                   'or the path to the weights file to be loaded.  '
                     f'Received: `weights={weights}.`')

  if weights == 'imagenet' and include_top and classes != 1000:
    raise ValueError('If using `weights` as `"imagenet"` with `include_top` '
                     'as true, `classes` should be 1000.  '
                     f'Received: `classes={classes}.`')
  # Determine proper input shape
  input_shape = imagenet_utils.obtain_input_shape(

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 123 Column: 1

                                   f'Received: `weights={weights}.`')

  if weights == 'imagenet' and include_top and classes != 1000:
    raise ValueError('If using `weights` as `"imagenet"` with `include_top` '
                     'as true, `classes` should be 1000.  '
                     f'Received: `classes={classes}.`')
  # Determine proper input shape
  input_shape = imagenet_utils.obtain_input_shape(
      input_shape,

            

Reported by Pylint.

keras/integration_test/parameter_server_custom_training_loop_test.py
68 issues
Unable to import 'absl'
Error

Line: 20 Column: 1

              from __future__ import division
from __future__ import print_function
import multiprocessing
from absl import logging
import portpicker
import tensorflow as tf

NUM_EPOCHS = 10
NUM_STEPS = 100

            

Reported by Pylint.

Unable to import 'portpicker'
Error

Line: 21 Column: 1

              from __future__ import print_function
import multiprocessing
from absl import logging
import portpicker
import tensorflow as tf

NUM_EPOCHS = 10
NUM_STEPS = 100
STEPS_PER_EXECUTION = 10

            

Reported by Pylint.

Unable to import 'tensorflow'
Error

Line: 22 Column: 1

              import multiprocessing
from absl import logging
import portpicker
import tensorflow as tf

NUM_EPOCHS = 10
NUM_STEPS = 100
STEPS_PER_EXECUTION = 10


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              

class ParameterServerCustomTrainingLoopTest(tf.test.TestCase):
  """Test to demonstrate custom training loop with ParameterServerStrategy."""

  def create_in_process_cluster(self, num_workers, num_ps):
    """Creates and starts local servers and returns the cluster_resolver."""
    worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)]
    ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]

            

Reported by Pylint.

Method could be a function
Error

Line: 32 Column: 3

              class ParameterServerCustomTrainingLoopTest(tf.test.TestCase):
  """Test to demonstrate custom training loop with ParameterServerStrategy."""

  def create_in_process_cluster(self, num_workers, num_ps):
    """Creates and starts local servers and returns the cluster_resolver."""
    worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)]
    ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]

    cluster_dict = {}

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              class ParameterServerCustomTrainingLoopTest(tf.test.TestCase):
  """Test to demonstrate custom training loop with ParameterServerStrategy."""

  def create_in_process_cluster(self, num_workers, num_ps):
    """Creates and starts local servers and returns the cluster_resolver."""
    worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)]
    ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]

    cluster_dict = {}

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 33 Column: 1

                """Test to demonstrate custom training loop with ParameterServerStrategy."""

  def create_in_process_cluster(self, num_workers, num_ps):
    """Creates and starts local servers and returns the cluster_resolver."""
    worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)]
    ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]

    cluster_dict = {}
    cluster_dict["worker"] = ["localhost:%s" % port for port in worker_ports]

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 34 Column: 1

              
  def create_in_process_cluster(self, num_workers, num_ps):
    """Creates and starts local servers and returns the cluster_resolver."""
    worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)]
    ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]

    cluster_dict = {}
    cluster_dict["worker"] = ["localhost:%s" % port for port in worker_ports]
    if num_ps > 0:

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 35 Column: 1

                def create_in_process_cluster(self, num_workers, num_ps):
    """Creates and starts local servers and returns the cluster_resolver."""
    worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)]
    ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]

    cluster_dict = {}
    cluster_dict["worker"] = ["localhost:%s" % port for port in worker_ports]
    if num_ps > 0:
      cluster_dict["ps"] = ["localhost:%s" % port for port in ps_ports]

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 37 Column: 1

                  worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)]
    ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]

    cluster_dict = {}
    cluster_dict["worker"] = ["localhost:%s" % port for port in worker_ports]
    if num_ps > 0:
      cluster_dict["ps"] = ["localhost:%s" % port for port in ps_ports]

    cluster_spec = tf.train.ClusterSpec(cluster_dict)

            

Reported by Pylint.

keras/applications/applications_test.py
68 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Integration tests for Keras applications."""

import tensorflow.compat.v2 as tf

from absl.testing import parameterized

from keras import backend
from keras.applications import densenet

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

from absl.testing import parameterized

from keras import backend
from keras.applications import densenet
from keras.applications import efficientnet
from keras.applications import inception_resnet_v2

            

Reported by Pylint.

Missing class docstring
Error

Line: 74 Column: 1

              MODEL_LIST = MODEL_LIST_NO_NASNET + NASNET_LIST


class ApplicationsTest(tf.test.TestCase, parameterized.TestCase):

  def assertShapeEqual(self, shape1, shape2):
    if len(shape1) != len(shape2):
      raise AssertionError(
          'Shapes are different rank: %s vs %s' % (shape1, shape2))

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 76 Column: 1

              
class ApplicationsTest(tf.test.TestCase, parameterized.TestCase):

  def assertShapeEqual(self, shape1, shape2):
    if len(shape1) != len(shape2):
      raise AssertionError(
          'Shapes are different rank: %s vs %s' % (shape1, shape2))
    for v1, v2 in zip(shape1, shape2):
      if v1 != v2:

            

Reported by Pylint.

Method name "assertShapeEqual" doesn't conform to snake_case naming style
Error

Line: 76 Column: 3

              
class ApplicationsTest(tf.test.TestCase, parameterized.TestCase):

  def assertShapeEqual(self, shape1, shape2):
    if len(shape1) != len(shape2):
      raise AssertionError(
          'Shapes are different rank: %s vs %s' % (shape1, shape2))
    for v1, v2 in zip(shape1, shape2):
      if v1 != v2:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 76 Column: 3

              
class ApplicationsTest(tf.test.TestCase, parameterized.TestCase):

  def assertShapeEqual(self, shape1, shape2):
    if len(shape1) != len(shape2):
      raise AssertionError(
          'Shapes are different rank: %s vs %s' % (shape1, shape2))
    for v1, v2 in zip(shape1, shape2):
      if v1 != v2:

            

Reported by Pylint.

Method could be a function
Error

Line: 76 Column: 3

              
class ApplicationsTest(tf.test.TestCase, parameterized.TestCase):

  def assertShapeEqual(self, shape1, shape2):
    if len(shape1) != len(shape2):
      raise AssertionError(
          'Shapes are different rank: %s vs %s' % (shape1, shape2))
    for v1, v2 in zip(shape1, shape2):
      if v1 != v2:

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 77 Column: 1

              class ApplicationsTest(tf.test.TestCase, parameterized.TestCase):

  def assertShapeEqual(self, shape1, shape2):
    if len(shape1) != len(shape2):
      raise AssertionError(
          'Shapes are different rank: %s vs %s' % (shape1, shape2))
    for v1, v2 in zip(shape1, shape2):
      if v1 != v2:
        raise AssertionError('Shapes differ: %s vs %s' % (shape1, shape2))

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 78 Column: 1

              
  def assertShapeEqual(self, shape1, shape2):
    if len(shape1) != len(shape2):
      raise AssertionError(
          'Shapes are different rank: %s vs %s' % (shape1, shape2))
    for v1, v2 in zip(shape1, shape2):
      if v1 != v2:
        raise AssertionError('Shapes differ: %s vs %s' % (shape1, shape2))


            

Reported by Pylint.

Variable name "v2" doesn't conform to snake_case naming style
Error

Line: 80 Column: 13

                  if len(shape1) != len(shape2):
      raise AssertionError(
          'Shapes are different rank: %s vs %s' % (shape1, shape2))
    for v1, v2 in zip(shape1, shape2):
      if v1 != v2:
        raise AssertionError('Shapes differ: %s vs %s' % (shape1, shape2))

  @parameterized.parameters(*MODEL_LIST)
  def test_application_base(self, app, _):

            

Reported by Pylint.

keras/benchmarks/keras_examples_benchmarks/antirectifier_benchmark_test.py
67 issues
Unable to import 'tensorflow'
Error

Line: 20 Column: 1

              from __future__ import division
from __future__ import print_function

import tensorflow as tf

from keras.benchmarks import benchmark_util


class AntirectifierBenchmark(tf.test.Benchmark):

            

Reported by Pylint.

Unable to import 'keras.benchmarks'
Error

Line: 22 Column: 1

              
import tensorflow as tf

from keras.benchmarks import benchmark_util


class AntirectifierBenchmark(tf.test.Benchmark):
  """Benchmarks for Antirectifier using `tf.test.Benchmark`."""


            

Reported by Pylint.

Attribute 'kernel' defined outside __init__
Error

Line: 139 Column: 5

              
  def build(self, input_shape):
    output_dim = input_shape[-1]
    self.kernel = self.add_weight(
        shape=(output_dim * 2, output_dim),
        initializer=self.initializer,
        name="kernel",
        trainable=True,
    )

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 26 Column: 1

              

class AntirectifierBenchmark(tf.test.Benchmark):
  """Benchmarks for Antirectifier using `tf.test.Benchmark`."""

  def __init__(self):
    super(AntirectifierBenchmark, self).__init__()
    (self.x_train, self.y_train), _ = tf.keras.datasets.mnist.load_data()
    self.x_train = self.x_train.reshape(-1, 784)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 28 Column: 1

              class AntirectifierBenchmark(tf.test.Benchmark):
  """Benchmarks for Antirectifier using `tf.test.Benchmark`."""

  def __init__(self):
    super(AntirectifierBenchmark, self).__init__()
    (self.x_train, self.y_train), _ = tf.keras.datasets.mnist.load_data()
    self.x_train = self.x_train.reshape(-1, 784)
    self.x_train = self.x_train.astype("float32") / 255


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 29 Column: 1

                """Benchmarks for Antirectifier using `tf.test.Benchmark`."""

  def __init__(self):
    super(AntirectifierBenchmark, self).__init__()
    (self.x_train, self.y_train), _ = tf.keras.datasets.mnist.load_data()
    self.x_train = self.x_train.reshape(-1, 784)
    self.x_train = self.x_train.astype("float32") / 255

  def _build_model(self):

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 29 Column: 5

                """Benchmarks for Antirectifier using `tf.test.Benchmark`."""

  def __init__(self):
    super(AntirectifierBenchmark, self).__init__()
    (self.x_train, self.y_train), _ = tf.keras.datasets.mnist.load_data()
    self.x_train = self.x_train.reshape(-1, 784)
    self.x_train = self.x_train.astype("float32") / 255

  def _build_model(self):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 30 Column: 1

              
  def __init__(self):
    super(AntirectifierBenchmark, self).__init__()
    (self.x_train, self.y_train), _ = tf.keras.datasets.mnist.load_data()
    self.x_train = self.x_train.reshape(-1, 784)
    self.x_train = self.x_train.astype("float32") / 255

  def _build_model(self):
    """Model from https://keras.io/examples/keras_recipes/antirectifier/."""

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 31 Column: 1

                def __init__(self):
    super(AntirectifierBenchmark, self).__init__()
    (self.x_train, self.y_train), _ = tf.keras.datasets.mnist.load_data()
    self.x_train = self.x_train.reshape(-1, 784)
    self.x_train = self.x_train.astype("float32") / 255

  def _build_model(self):
    """Model from https://keras.io/examples/keras_recipes/antirectifier/."""
    model = tf.keras.Sequential([

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 32 Column: 1

                  super(AntirectifierBenchmark, self).__init__()
    (self.x_train, self.y_train), _ = tf.keras.datasets.mnist.load_data()
    self.x_train = self.x_train.reshape(-1, 784)
    self.x_train = self.x_train.astype("float32") / 255

  def _build_model(self):
    """Model from https://keras.io/examples/keras_recipes/antirectifier/."""
    model = tf.keras.Sequential([
        tf.keras.Input(shape=(784,)),

            

Reported by Pylint.

keras/layers/embeddings_test.py
66 issues
Bad option value 'g-direct-tensorflow-import'
Error

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================
"""Tests for embedding layers."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import

import keras
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils

            

Reported by Pylint.

Bad option value 'g-classes-have-attributes'
Error

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================
"""Tests for embedding layers."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import

import keras
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 24 Column: 1

              from keras import testing_utils
from keras.mixed_precision import policy
import numpy as np
import tensorflow.compat.v2 as tf


class EmbeddingTest(keras_parameterized.TestCase):

  @keras_parameterized.run_all_keras_modes

            

Reported by Pylint.

Access to a protected member _dtype_policy of a client class
Error

Line: 130 Column: 24

                  try:
      policy.set_policy('mixed_float16')
      layer = keras.layers.Embedding(input_dim=5, output_dim=2)
      self.assertEqual(layer._dtype_policy.name, 'mixed_float16')
      outputs = layer(np.array([0, 1, 2]))
      self.assertEqual(outputs.dtype, 'float16')
    finally:
      policy.set_policy('float32')


            

Reported by Pylint.

Missing class docstring
Error

Line: 27 Column: 1

              import tensorflow.compat.v2 as tf


class EmbeddingTest(keras_parameterized.TestCase):

  @keras_parameterized.run_all_keras_modes
  def test_embedding(self):
    if tf.test.is_gpu_available():
      self.skipTest('Only test embedding on CPU.')

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 29 Column: 1

              
class EmbeddingTest(keras_parameterized.TestCase):

  @keras_parameterized.run_all_keras_modes
  def test_embedding(self):
    if tf.test.is_gpu_available():
      self.skipTest('Only test embedding on CPU.')

    testing_utils.layer_test(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 3

              class EmbeddingTest(keras_parameterized.TestCase):

  @keras_parameterized.run_all_keras_modes
  def test_embedding(self):
    if tf.test.is_gpu_available():
      self.skipTest('Only test embedding on CPU.')

    testing_utils.layer_test(
        keras.layers.Embedding,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              class EmbeddingTest(keras_parameterized.TestCase):

  @keras_parameterized.run_all_keras_modes
  def test_embedding(self):
    if tf.test.is_gpu_available():
      self.skipTest('Only test embedding on CPU.')

    testing_utils.layer_test(
        keras.layers.Embedding,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 31 Column: 1

              
  @keras_parameterized.run_all_keras_modes
  def test_embedding(self):
    if tf.test.is_gpu_available():
      self.skipTest('Only test embedding on CPU.')

    testing_utils.layer_test(
        keras.layers.Embedding,
        kwargs={'output_dim': 4,

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 32 Column: 1

                @keras_parameterized.run_all_keras_modes
  def test_embedding(self):
    if tf.test.is_gpu_available():
      self.skipTest('Only test embedding on CPU.')

    testing_utils.layer_test(
        keras.layers.Embedding,
        kwargs={'output_dim': 4,
                'input_dim': 10,

            

Reported by Pylint.

keras/optimizer_v2/ftrl.py
66 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Ftrl-proximal optimizer implementation."""

import tensorflow.compat.v2 as tf
# pylint: disable=g-classes-have-attributes

from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export


            

Reported by Pylint.

Bad option value 'g-classes-have-attributes'
Error

Line: 18 Column: 1

              """Ftrl-proximal optimizer implementation."""

import tensorflow.compat.v2 as tf
# pylint: disable=g-classes-have-attributes

from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export



            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf
# pylint: disable=g-classes-have-attributes

from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.optimizers.Ftrl')
class Ftrl(optimizer_v2.OptimizerV2):

            

Reported by Pylint.

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

Line: 21 Column: 1

              # pylint: disable=g-classes-have-attributes

from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.optimizers.Ftrl')
class Ftrl(optimizer_v2.OptimizerV2):
  r"""Optimizer that implements the FTRL algorithm.

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 25 Column: 1

              

@keras_export('keras.optimizers.Ftrl')
class Ftrl(optimizer_v2.OptimizerV2):
  r"""Optimizer that implements the FTRL algorithm.

  "Follow The Regularized Leader" (FTRL) is an optimization algorithm developed
  at Google for click-through rate prediction in the early 2010s. It is most
  suitable for shallow models with large and sparse feature spaces.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 26 Column: 1

              
@keras_export('keras.optimizers.Ftrl')
class Ftrl(optimizer_v2.OptimizerV2):
  r"""Optimizer that implements the FTRL algorithm.

  "Follow The Regularized Leader" (FTRL) is an optimization algorithm developed
  at Google for click-through rate prediction in the early 2010s. It is most
  suitable for shallow models with large and sparse feature spaces.
  The algorithm is described by

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 100 Column: 1

                    https://research.google.com/pubs/archive/41159.pdf)
  """

  def __init__(self,
               learning_rate=0.001,
               learning_rate_power=-0.5,
               initial_accumulator_value=0.1,
               l1_regularization_strength=0.0,
               l2_regularization_strength=0.0,

            

Reported by Pylint.

Too many arguments (9/5)
Error

Line: 100 Column: 3

                    https://research.google.com/pubs/archive/41159.pdf)
  """

  def __init__(self,
               learning_rate=0.001,
               learning_rate_power=-0.5,
               initial_accumulator_value=0.1,
               l1_regularization_strength=0.0,
               l2_regularization_strength=0.0,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 110 Column: 1

                             l2_shrinkage_regularization_strength=0.0,
               beta=0.0,
               **kwargs):
    super(Ftrl, self).__init__(name, **kwargs)

    if initial_accumulator_value < 0.0:
      raise ValueError(
          '`initial_accumulator_value` needs to be positive or zero. Received: '
          f'initial_accumulator_value={initial_accumulator_value}.')

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 110 Column: 5

                             l2_shrinkage_regularization_strength=0.0,
               beta=0.0,
               **kwargs):
    super(Ftrl, self).__init__(name, **kwargs)

    if initial_accumulator_value < 0.0:
      raise ValueError(
          '`initial_accumulator_value` needs to be positive or zero. Received: '
          f'initial_accumulator_value={initial_accumulator_value}.')

            

Reported by Pylint.

keras/layers/preprocessing/hashing.py
66 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Keras hashing preprocessing layer."""

import tensorflow.compat.v2 as tf
# pylint: disable=g-classes-have-attributes

import functools
import numpy as np
from keras.engine import base_layer

            

Reported by Pylint.

Bad option value 'g-classes-have-attributes'
Error

Line: 18 Column: 1

              """Keras hashing preprocessing layer."""

import tensorflow.compat.v2 as tf
# pylint: disable=g-classes-have-attributes

import functools
import numpy as np
from keras.engine import base_layer
from keras.engine import base_preprocessing_layer

            

Reported by Pylint.

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

Line: 24 Column: 1

              import numpy as np
from keras.engine import base_layer
from keras.engine import base_preprocessing_layer
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.layers.Hashing',
              'keras.layers.experimental.preprocessing.Hashing')
class Hashing(base_layer.Layer):

            

Reported by Pylint.

Parameters differ from overridden 'call' method
Error

Line: 146 Column: 3

                          f'The `salt` argument for `Hashing` can only be a tuple of size 2 '
            f'integers, or a single integer. Received: salt={salt}.')

  def call(self, inputs):
    if isinstance(inputs, (list, tuple, np.ndarray)):
      inputs = tf.convert_to_tensor(inputs)
    if isinstance(inputs, tf.SparseTensor):
      return tf.SparseTensor(
          indices=inputs.indices,

            

Reported by Pylint.

Parameters differ from overridden 'compute_output_signature' method
Error

Line: 187 Column: 3

                def compute_output_shape(self, input_shape):
    return input_shape

  def compute_output_signature(self, input_spec):
    output_shape = self.compute_output_shape(input_spec.shape)
    output_dtype = tf.int64
    if isinstance(input_spec, tf.SparseTensorSpec):
      return tf.SparseTensorSpec(
          shape=output_shape, dtype=output_dtype)

            

Reported by Pylint.

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

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf
# pylint: disable=g-classes-have-attributes

import functools
import numpy as np
from keras.engine import base_layer
from keras.engine import base_preprocessing_layer
from tensorflow.python.util.tf_export import keras_export


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              @keras_export('keras.layers.Hashing',
              'keras.layers.experimental.preprocessing.Hashing')
class Hashing(base_layer.Layer):
  """Implements categorical feature hashing, also known as "hashing trick".

  This layer transforms single or multiple categorical inputs to hashed output.
  It converts a sequence of int or string to a sequence of int. The stable hash
  function uses `tensorflow::ops::Fingerprint` to produce the same output
  consistently across all platforms.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 125 Column: 1

              
  """

  def __init__(self, num_bins, mask_value=None, salt=None, **kwargs):
    if num_bins is None or num_bins <= 0:
      raise ValueError(
          f'The `num_bins` for `Hashing` cannot be `None` or non-positive '
          f'values. Received: num_bins={num_bins}.')
    super().__init__(**kwargs)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 126 Column: 1

                """

  def __init__(self, num_bins, mask_value=None, salt=None, **kwargs):
    if num_bins is None or num_bins <= 0:
      raise ValueError(
          f'The `num_bins` for `Hashing` cannot be `None` or non-positive '
          f'values. Received: num_bins={num_bins}.')
    super().__init__(**kwargs)
    base_preprocessing_layer.keras_kpl_gauge.get_cell('Hashing').set(True)

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 127 Column: 1

              
  def __init__(self, num_bins, mask_value=None, salt=None, **kwargs):
    if num_bins is None or num_bins <= 0:
      raise ValueError(
          f'The `num_bins` for `Hashing` cannot be `None` or non-positive '
          f'values. Received: num_bins={num_bins}.')
    super().__init__(**kwargs)
    base_preprocessing_layer.keras_kpl_gauge.get_cell('Hashing').set(True)
    self.num_bins = num_bins

            

Reported by Pylint.

keras/engine/base_layer_utils_test.py
65 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 18 Column: 1

              
import numpy as np

import tensorflow.compat.v2 as tf

import keras
from keras import backend
from keras import combinations
from keras import keras_parameterized

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Copyright 2019 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
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software

            

Reported by Pylint.

Missing class docstring
Error

Line: 28 Column: 1

              

@combinations.generate(combinations.combine(mode=['graph', 'eager']))
class TrackableWeightHandlerTest(keras_parameterized.TestCase):

  def get_table_handler(self):
    # Note: There is some repetition in these tests' setup. However, Tensorflow
    # does not play nicely with a separate setUp() call (causing errors related
    # to graph building), so we have to use a called setup instead of a setUp()

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              @combinations.generate(combinations.combine(mode=['graph', 'eager']))
class TrackableWeightHandlerTest(keras_parameterized.TestCase):

  def get_table_handler(self):
    # Note: There is some repetition in these tests' setup. However, Tensorflow
    # does not play nicely with a separate setUp() call (causing errors related
    # to graph building), so we have to use a called setup instead of a setUp()
    # call.
    table = tf.lookup.experimental.MutableHashTable(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 3

              @combinations.generate(combinations.combine(mode=['graph', 'eager']))
class TrackableWeightHandlerTest(keras_parameterized.TestCase):

  def get_table_handler(self):
    # Note: There is some repetition in these tests' setup. However, Tensorflow
    # does not play nicely with a separate setUp() call (causing errors related
    # to graph building), so we have to use a called setup instead of a setUp()
    # call.
    table = tf.lookup.experimental.MutableHashTable(

            

Reported by Pylint.

Method could be a function
Error

Line: 30 Column: 3

              @combinations.generate(combinations.combine(mode=['graph', 'eager']))
class TrackableWeightHandlerTest(keras_parameterized.TestCase):

  def get_table_handler(self):
    # Note: There is some repetition in these tests' setup. However, Tensorflow
    # does not play nicely with a separate setUp() call (causing errors related
    # to graph building), so we have to use a called setup instead of a setUp()
    # call.
    table = tf.lookup.experimental.MutableHashTable(

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 35 Column: 1

                  # does not play nicely with a separate setUp() call (causing errors related
    # to graph building), so we have to use a called setup instead of a setUp()
    # call.
    table = tf.lookup.experimental.MutableHashTable(
        key_dtype=tf.string, value_dtype=tf.int32, default_value=0)
    return base_layer_utils.TrackableWeightHandler(table)

  def test_get_num_tensors(self):
    table_handler = self.get_table_handler()

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 37 Column: 1

                  # call.
    table = tf.lookup.experimental.MutableHashTable(
        key_dtype=tf.string, value_dtype=tf.int32, default_value=0)
    return base_layer_utils.TrackableWeightHandler(table)

  def test_get_num_tensors(self):
    table_handler = self.get_table_handler()
    self.assertEqual(2, table_handler.num_tensors)


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 39 Column: 1

                      key_dtype=tf.string, value_dtype=tf.int32, default_value=0)
    return base_layer_utils.TrackableWeightHandler(table)

  def test_get_num_tensors(self):
    table_handler = self.get_table_handler()
    self.assertEqual(2, table_handler.num_tensors)

  def test_get_and_set_weights(self):
    table_handler = self.get_table_handler()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 3

                      key_dtype=tf.string, value_dtype=tf.int32, default_value=0)
    return base_layer_utils.TrackableWeightHandler(table)

  def test_get_num_tensors(self):
    table_handler = self.get_table_handler()
    self.assertEqual(2, table_handler.num_tensors)

  def test_get_and_set_weights(self):
    table_handler = self.get_table_handler()

            

Reported by Pylint.

keras/saving/losses_serialization_test.py
65 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for Keras losses serialization."""

import tensorflow.compat.v2 as tf

import os
import shutil

from absl.testing import parameterized

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 22 Column: 1

              import os
import shutil

from absl.testing import parameterized
import numpy as np

import keras
from keras import keras_parameterized
from keras import layers

            

Reported by Pylint.

Bad option value 'g-import-not-at-top'
Error

Line: 35 Column: 1

              from keras.utils import losses_utils

try:
  import h5py  # pylint:disable=g-import-not-at-top
except ImportError:
  h5py = None


# Custom loss class

            

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
import shutil

from absl.testing import parameterized
import numpy as np


            

Reported by Pylint.

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

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf

import os
import shutil

from absl.testing import parameterized
import numpy as np

import keras

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 35 Column: 1

              from keras.utils import losses_utils

try:
  import h5py  # pylint:disable=g-import-not-at-top
except ImportError:
  h5py = None


# Custom loss class

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 37 Column: 1

              try:
  import h5py  # pylint:disable=g-import-not-at-top
except ImportError:
  h5py = None


# Custom loss class
class MyMeanAbsoluteError(losses.LossFunctionWrapper):


            

Reported by Pylint.

Missing class docstring
Error

Line: 41 Column: 1

              

# Custom loss class
class MyMeanAbsoluteError(losses.LossFunctionWrapper):

  def __init__(self,
               reduction=losses_utils.ReductionV2.AUTO,
               name='mean_absolute_error'):
    super(MyMeanAbsoluteError, self).__init__(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 43 Column: 1

              # Custom loss class
class MyMeanAbsoluteError(losses.LossFunctionWrapper):

  def __init__(self,
               reduction=losses_utils.ReductionV2.AUTO,
               name='mean_absolute_error'):
    super(MyMeanAbsoluteError, self).__init__(
        my_mae, name=name, reduction=reduction)


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 46 Column: 1

                def __init__(self,
               reduction=losses_utils.ReductionV2.AUTO,
               name='mean_absolute_error'):
    super(MyMeanAbsoluteError, self).__init__(
        my_mae, name=name, reduction=reduction)


# Custom loss function
def my_mae(y_true, y_pred):

            

Reported by Pylint.

keras/distribute/keras_premade_models_test.py
65 issues
Unable to import 'absl.testing'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for keras premade models using tf.distribute.Strategy."""

from absl.testing import parameterized

from keras.engine import sequential
from keras.layers import core
from keras.optimizer_v2 import adagrad
from keras.optimizer_v2 import gradient_descent

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 27 Column: 1

              from keras.premade import wide_deep
from keras.utils import dataset_creator
import numpy as np
import tensorflow.compat.v2 as tf


def strategy_combinations_eager_data_fn():
  return tf.__internal__.test.combinations.combine(
      distribution=[

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 1

              import tensorflow.compat.v2 as tf


def strategy_combinations_eager_data_fn():
  return tf.__internal__.test.combinations.combine(
      distribution=[
          tf.__internal__.distribute.combinations.default_strategy,
          tf.__internal__.distribute.combinations.one_device_strategy,
          tf.__internal__.distribute.combinations.one_device_strategy_gpu,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 31 Column: 1

              

def strategy_combinations_eager_data_fn():
  return tf.__internal__.test.combinations.combine(
      distribution=[
          tf.__internal__.distribute.combinations.default_strategy,
          tf.__internal__.distribute.combinations.one_device_strategy,
          tf.__internal__.distribute.combinations.one_device_strategy_gpu,
          tf.__internal__.distribute.combinations

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 61 Column: 1

              BATCH_SIZE = 10


def get_numpy():
  inputs = np.random.uniform(
      low=-5., high=5., size=(INPUT_SIZE, 2)).astype(np.float32)
  output = .3 * inputs[:, 0] + .2 * inputs[:, 1]
  return inputs, output


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 62 Column: 1

              

def get_numpy():
  inputs = np.random.uniform(
      low=-5., high=5., size=(INPUT_SIZE, 2)).astype(np.float32)
  output = .3 * inputs[:, 0] + .2 * inputs[:, 1]
  return inputs, output



            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 64 Column: 1

              def get_numpy():
  inputs = np.random.uniform(
      low=-5., high=5., size=(INPUT_SIZE, 2)).astype(np.float32)
  output = .3 * inputs[:, 0] + .2 * inputs[:, 1]
  return inputs, output


def get_dataset(input_context=None, batch_size=None):
  inputs, output = get_numpy()

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 65 Column: 1

                inputs = np.random.uniform(
      low=-5., high=5., size=(INPUT_SIZE, 2)).astype(np.float32)
  output = .3 * inputs[:, 0] + .2 * inputs[:, 1]
  return inputs, output


def get_dataset(input_context=None, batch_size=None):
  inputs, output = get_numpy()
  dataset = tf.data.Dataset.from_tensor_slices((inputs, output))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 68 Column: 1

                return inputs, output


def get_dataset(input_context=None, batch_size=None):
  inputs, output = get_numpy()
  dataset = tf.data.Dataset.from_tensor_slices((inputs, output))
  if input_context:
    dataset = dataset.shard(input_context.num_input_pipelines,
                            input_context.input_pipeline_id)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 69 Column: 1

              

def get_dataset(input_context=None, batch_size=None):
  inputs, output = get_numpy()
  dataset = tf.data.Dataset.from_tensor_slices((inputs, output))
  if input_context:
    dataset = dataset.shard(input_context.num_input_pipelines,
                            input_context.input_pipeline_id)
  if batch_size is None:

            

Reported by Pylint.