The following issues were found

keras/applications/vgg16.py
65 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/'
                'vgg16/vgg16_weights_tf_dim_ordering_tf_kernels.h5')
WEIGHTS_PATH_NO_TOP = ('https://storage.googleapis.com/tensorflow/'

            

Reported by Pylint.

Too many statements (53/50)
Error

Line: 44 Column: 1

              

@keras_export('keras.applications.vgg16.VGG16', 'keras.applications.VGG16')
def VGG16(
    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.vgg16.VGG16', 'keras.applications.VGG16')
def VGG16(
    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.vgg16.VGG16', 'keras.applications.VGG16')
def VGG16(
    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 VGG16 model.

  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.  Received: '

            

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.  Received: '
        f'weights={weights}')

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 123 Column: 1

                      'or the path to the weights file to be loaded.  Received: '
        f'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: 124 Column: 1

                      f'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/preprocessing/image_dataset.py
65 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Keras image dataset loading utilities."""

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

import numpy as np
from keras.layers.preprocessing import image_preprocessing
from keras.preprocessing import dataset_utils

            

Reported by Pylint.

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

Line: 18 Column: 1

              """Keras image dataset loading utilities."""

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

import numpy as np
from keras.layers.preprocessing import image_preprocessing
from keras.preprocessing import dataset_utils
from keras.preprocessing import image as keras_image_ops

            

Reported by Pylint.

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

Line: 24 Column: 1

              from keras.layers.preprocessing import image_preprocessing
from keras.preprocessing import dataset_utils
from keras.preprocessing import image as keras_image_ops
from tensorflow.python.util.tf_export import keras_export


ALLOWLIST_FORMATS = ('.bmp', '.gif', '.jpeg', '.jpg', '.png')



            

Reported by Pylint.

TODO(fchollet): consider making num_parallel_calls settable
Error

Line: 239 Column: 3

                                              interpolation,
                                crop_to_aspect_ratio=False):
  """Constructs a dataset of images and labels."""
  # TODO(fchollet): consider making num_parallel_calls settable
  path_ds = tf.data.Dataset.from_tensor_slices(image_paths)
  args = (image_size, num_channels, interpolation, crop_to_aspect_ratio)
  img_ds = path_ds.map(
      lambda x: load_image(x, *args))
  if label_mode:

            

Reported by Pylint.

Too many local variables (18/15)
Error

Line: 33 Column: 1

              @keras_export('keras.utils.image_dataset_from_directory',
              'keras.preprocessing.image_dataset_from_directory',
              v1=[])
def image_dataset_from_directory(directory,
                                 labels='inferred',
                                 label_mode='int',
                                 class_names=None,
                                 color_mode='rgb',
                                 batch_size=32,

            

Reported by Pylint.

Too many branches (15/12)
Error

Line: 33 Column: 1

              @keras_export('keras.utils.image_dataset_from_directory',
              'keras.preprocessing.image_dataset_from_directory',
              v1=[])
def image_dataset_from_directory(directory,
                                 labels='inferred',
                                 label_mode='int',
                                 class_names=None,
                                 color_mode='rgb',
                                 batch_size=32,

            

Reported by Pylint.

Too many arguments (14/5)
Error

Line: 33 Column: 1

              @keras_export('keras.utils.image_dataset_from_directory',
              'keras.preprocessing.image_dataset_from_directory',
              v1=[])
def image_dataset_from_directory(directory,
                                 labels='inferred',
                                 label_mode='int',
                                 class_names=None,
                                 color_mode='rgb',
                                 batch_size=32,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 48 Column: 1

                                               follow_links=False,
                                 crop_to_aspect_ratio=False,
                                 **kwargs):
  """Generates a `tf.data.Dataset` from image files in a directory.

  If your directory structure is:

  ```
  main_directory/

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 150 Column: 1

                  - if `color_mode` is `rgba`,
      there are 4 channel in the image tensors.
  """
  if 'smart_resize' in kwargs:
    crop_to_aspect_ratio = kwargs.pop('smart_resize')
  if kwargs:
    raise TypeError(f'Unknown keywords argument(s): {tuple(kwargs.keys())}')
  if labels not in ('inferred', None):
    if not isinstance(labels, (list, tuple)):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 151 Column: 1

                    there are 4 channel in the image tensors.
  """
  if 'smart_resize' in kwargs:
    crop_to_aspect_ratio = kwargs.pop('smart_resize')
  if kwargs:
    raise TypeError(f'Unknown keywords argument(s): {tuple(kwargs.keys())}')
  if labels not in ('inferred', None):
    if not isinstance(labels, (list, tuple)):
      raise ValueError(

            

Reported by Pylint.

keras/engine/partial_batch_padding_handler.py
64 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Utility object to handler partial batches for TPUStrategy."""

import tensorflow.compat.v2 as tf
# pylint: disable=protected-access

import numpy as np
from keras import backend


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 25 Column: 1

              

class PartialBatchPaddingHandler:
  """A container that holds info about partial batches for `predict()`."""

  def __init__(self, output_shape):
    self.padded_batch_size = 0
    self.padding_mask = tf.zeros(0)
    self.output_shape = output_shape

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 27 Column: 1

              class PartialBatchPaddingHandler:
  """A container that holds info about partial batches for `predict()`."""

  def __init__(self, output_shape):
    self.padded_batch_size = 0
    self.padding_mask = tf.zeros(0)
    self.output_shape = output_shape

  def get_real_batch_size(self, dataset_batch):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 28 Column: 1

                """A container that holds info about partial batches for `predict()`."""

  def __init__(self, output_shape):
    self.padded_batch_size = 0
    self.padding_mask = tf.zeros(0)
    self.output_shape = output_shape

  def get_real_batch_size(self, dataset_batch):
    """Returns the number of elements in a potentially partial batch."""

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 29 Column: 1

              
  def __init__(self, output_shape):
    self.padded_batch_size = 0
    self.padding_mask = tf.zeros(0)
    self.output_shape = output_shape

  def get_real_batch_size(self, dataset_batch):
    """Returns the number of elements in a potentially partial batch."""
    if isinstance(dataset_batch, (tuple, list)):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 30 Column: 1

                def __init__(self, output_shape):
    self.padded_batch_size = 0
    self.padding_mask = tf.zeros(0)
    self.output_shape = output_shape

  def get_real_batch_size(self, dataset_batch):
    """Returns the number of elements in a potentially partial batch."""
    if isinstance(dataset_batch, (tuple, list)):
      dataset_batch = dataset_batch[0]

            

Reported by Pylint.

Method could be a function
Error

Line: 32 Column: 3

                  self.padding_mask = tf.zeros(0)
    self.output_shape = output_shape

  def get_real_batch_size(self, dataset_batch):
    """Returns the number of elements in a potentially partial batch."""
    if isinstance(dataset_batch, (tuple, list)):
      dataset_batch = dataset_batch[0]

    assert tf.nest.flatten(dataset_batch)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

                  self.padding_mask = tf.zeros(0)
    self.output_shape = output_shape

  def get_real_batch_size(self, dataset_batch):
    """Returns the number of elements in a potentially partial batch."""
    if isinstance(dataset_batch, (tuple, list)):
      dataset_batch = dataset_batch[0]

    assert tf.nest.flatten(dataset_batch)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 33 Column: 1

                  self.output_shape = output_shape

  def get_real_batch_size(self, dataset_batch):
    """Returns the number of elements in a potentially partial batch."""
    if isinstance(dataset_batch, (tuple, list)):
      dataset_batch = dataset_batch[0]

    assert tf.nest.flatten(dataset_batch)


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 34 Column: 1

              
  def get_real_batch_size(self, dataset_batch):
    """Returns the number of elements in a potentially partial batch."""
    if isinstance(dataset_batch, (tuple, list)):
      dataset_batch = dataset_batch[0]

    assert tf.nest.flatten(dataset_batch)

    def _find_any_tensor(batch_features):

            

Reported by Pylint.

keras/optimizer_v2/adamax.py
64 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Adamax optimizer implementation."""

import tensorflow.compat.v2 as tf
from keras import backend_config
from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export



            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 18 Column: 1

              """Adamax optimizer implementation."""

import tensorflow.compat.v2 as tf
from keras import backend_config
from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.optimizers.Adamax')

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf
from keras import backend_config
from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export


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

            

Reported by Pylint.

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

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf
from keras import backend_config
from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export


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

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 24 Column: 1

              

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

  It is a variant of Adam based on the infinity norm.
  Default parameters follow those provided in the paper.
  Adamax is sometimes superior to adam, specially in models with embeddings.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 25 Column: 1

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

  It is a variant of Adam based on the infinity norm.
  Default parameters follow those provided in the paper.
  Adamax is sometimes superior to adam, specially in models with embeddings.


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 81 Column: 1

                  - [Kingma et al., 2014](http://arxiv.org/abs/1412.6980)
  """

  _HAS_AGGREGATE_GRAD = True

  def __init__(self,
               learning_rate=0.001,
               beta_1=0.9,
               beta_2=0.999,

            

Reported by Pylint.

Too many arguments (6/5)
Error

Line: 83 Column: 3

              
  _HAS_AGGREGATE_GRAD = True

  def __init__(self,
               learning_rate=0.001,
               beta_1=0.9,
               beta_2=0.999,
               epsilon=1e-7,
               name='Adamax',

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 83 Column: 1

              
  _HAS_AGGREGATE_GRAD = True

  def __init__(self,
               learning_rate=0.001,
               beta_1=0.9,
               beta_2=0.999,
               epsilon=1e-7,
               name='Adamax',

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 90 Column: 5

                             epsilon=1e-7,
               name='Adamax',
               **kwargs):
    super(Adamax, self).__init__(name, **kwargs)
    self._set_hyper('learning_rate', kwargs.get('lr', learning_rate))
    self._set_hyper('decay', self._initial_decay)
    self._set_hyper('beta_1', beta_1)
    self._set_hyper('beta_2', beta_2)
    self.epsilon = epsilon or backend_config.epsilon()

            

Reported by Pylint.

keras/benchmarks/distribution_util.py
64 issues
Unable to import 'tensorflow'
Error

Line: 21 Column: 1

              https://github.com/tensorflow/models/blob/master/official/utils/misc/distribution_utils.py.
"""

import tensorflow as tf

import json
import os



            

Reported by Pylint.

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

Line: 23 Column: 1

              
import tensorflow as tf

import json
import os


def _collective_communication(all_reduce_alg):
  """Return a CollectiveCommunication based on all_reduce_alg.

            

Reported by Pylint.

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

Line: 24 Column: 1

              import tensorflow as tf

import json
import os


def _collective_communication(all_reduce_alg):
  """Return a CollectiveCommunication based on all_reduce_alg.


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 28 Column: 1

              

def _collective_communication(all_reduce_alg):
  """Return a CollectiveCommunication based on all_reduce_alg.

  Args:
    all_reduce_alg: a string specifying which collective communication to pick,
      or None.


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 40 Column: 1

                Raises:
    ValueError: if `all_reduce_alg` not in [None, "ring", "nccl"]
  """
  collective_communication_options = {
      None: tf.distribute.experimental.CollectiveCommunication.AUTO,
      "ring": tf.distribute.experimental.CollectiveCommunication.RING,
      "nccl": tf.distribute.experimental.CollectiveCommunication.NCCL
  }
  if all_reduce_alg not in collective_communication_options:

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 45 Column: 1

                    "ring": tf.distribute.experimental.CollectiveCommunication.RING,
      "nccl": tf.distribute.experimental.CollectiveCommunication.NCCL
  }
  if all_reduce_alg not in collective_communication_options:
    raise ValueError(
        "When used with `multi_worker_mirrored`, valid values for "
        "all_reduce_alg are [`ring`, `nccl`].  Supplied value: {}".format(
            all_reduce_alg))
  return collective_communication_options[all_reduce_alg]

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 46 Column: 1

                    "nccl": tf.distribute.experimental.CollectiveCommunication.NCCL
  }
  if all_reduce_alg not in collective_communication_options:
    raise ValueError(
        "When used with `multi_worker_mirrored`, valid values for "
        "all_reduce_alg are [`ring`, `nccl`].  Supplied value: {}".format(
            all_reduce_alg))
  return collective_communication_options[all_reduce_alg]


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 50 Column: 1

                      "When used with `multi_worker_mirrored`, valid values for "
        "all_reduce_alg are [`ring`, `nccl`].  Supplied value: {}".format(
            all_reduce_alg))
  return collective_communication_options[all_reduce_alg]


def _mirrored_cross_device_ops(all_reduce_alg, num_packs):
  """Return a CrossDeviceOps based on all_reduce_alg and num_packs.


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 54 Column: 1

              

def _mirrored_cross_device_ops(all_reduce_alg, num_packs):
  """Return a CrossDeviceOps based on all_reduce_alg and num_packs.

  Args:
    all_reduce_alg: a string specifying which cross device op to pick, or None.
    num_packs: an integer specifying number of packs for the cross device op.


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 66 Column: 1

                Raises:
    ValueError: if `all_reduce_alg` not in [None, "nccl", "hierarchical_copy"].
  """
  if all_reduce_alg is None:
    return None
  mirrored_all_reduce_options = {
      "nccl": tf.distribute.NcclAllReduce,
      "hierarchical_copy": tf.distribute.HierarchicalCopyAllReduce
  }

            

Reported by Pylint.

keras/distribute/keras_optimizer_v2_test.py
64 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests that show that DistributionStrategy works with optimizer v2."""

import tensorflow.compat.v2 as tf

from absl.testing import parameterized
import numpy as np

import keras

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

from absl.testing import parameterized
import numpy as np

import keras
from keras.optimizer_v2 import adam
from keras.optimizer_v2 import gradient_descent

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 1

              from keras.optimizer_v2 import gradient_descent


def get_model():
  x = keras.layers.Input(shape=(3,), name='input')
  y = keras.layers.Dense(4, name='dense')(x)
  model = keras.Model(x, y)
  return model


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 28 Column: 1

              

def get_model():
  x = keras.layers.Input(shape=(3,), name='input')
  y = keras.layers.Dense(4, name='dense')(x)
  model = keras.Model(x, y)
  return model



            

Reported by Pylint.

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

Line: 28 Column: 3

              

def get_model():
  x = keras.layers.Input(shape=(3,), name='input')
  y = keras.layers.Dense(4, name='dense')(x)
  model = keras.Model(x, y)
  return model



            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 29 Column: 1

              
def get_model():
  x = keras.layers.Input(shape=(3,), name='input')
  y = keras.layers.Dense(4, name='dense')(x)
  model = keras.Model(x, y)
  return model


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

            

Reported by Pylint.

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

Line: 29 Column: 3

              
def get_model():
  x = keras.layers.Input(shape=(3,), name='input')
  y = keras.layers.Dense(4, name='dense')(x)
  model = keras.Model(x, y)
  return model


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

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              def get_model():
  x = keras.layers.Input(shape=(3,), name='input')
  y = keras.layers.Dense(4, name='dense')(x)
  model = keras.Model(x, y)
  return model


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


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 31 Column: 1

                x = keras.layers.Input(shape=(3,), name='input')
  y = keras.layers.Dense(4, name='dense')(x)
  model = keras.Model(x, y)
  return model


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

  @tf.__internal__.distribute.combinations.generate(

            

Reported by Pylint.

Missing class docstring
Error

Line: 34 Column: 1

                return model


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

  @tf.__internal__.distribute.combinations.generate(
      tf.__internal__.test.combinations.combine(
          distribution=[
              tf.__internal__.distribute.combinations.central_storage_strategy_with_two_gpus,

            

Reported by Pylint.

keras/distribute/keras_rnn_model_correctness_test.py
63 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Correctness tests for tf.keras RNN models using DistributionStrategy."""

import tensorflow.compat.v2 as tf

import numpy as np

import keras
from keras import testing_utils

            

Reported by Pylint.

Parameters differ from overridden 'get_model' method
Error

Line: 37 Column: 3

                def _get_layer_class(self):
    raise NotImplementedError

  def get_model(self,
                max_words=10,
                initial_weights=None,
                distribution=None,
                input_shapes=None):
    del input_shapes

            

Reported by Pylint.

Method 'get_data_with_partial_last_batch_eval' is abstract in class 'TestDistributionStrategyCorrectnessBase' but is not overridden
Error

Line: 69 Column: 1

              
@testing_utils.run_all_without_tensor_float_32(
    'Uses Dense layers, which call matmul')
class DistributionStrategyGruModelCorrectnessTest(
    _DistributionStrategyRnnModelCorrectnessTest):

  def _get_layer_class(self):
    if tf.__internal__.tf2.enabled():
      if not tf.executing_eagerly():

            

Reported by Pylint.

Method 'get_data_with_partial_last_batch' is abstract in class 'TestDistributionStrategyCorrectnessBase' but is not overridden
Error

Line: 69 Column: 1

              
@testing_utils.run_all_without_tensor_float_32(
    'Uses Dense layers, which call matmul')
class DistributionStrategyGruModelCorrectnessTest(
    _DistributionStrategyRnnModelCorrectnessTest):

  def _get_layer_class(self):
    if tf.__internal__.tf2.enabled():
      if not tf.executing_eagerly():

            

Reported by Pylint.

Method 'get_data_with_partial_last_batch_eval' is abstract in class 'TestDistributionStrategyCorrectnessBase' but is not overridden
Error

Line: 90 Column: 1

              
@testing_utils.run_all_without_tensor_float_32(
    'Uses Dense layers, which call matmul')
class DistributionStrategyLstmModelCorrectnessTest(
    _DistributionStrategyRnnModelCorrectnessTest):

  def _get_layer_class(self):
    if tf.__internal__.tf2.enabled():
      if not tf.executing_eagerly():

            

Reported by Pylint.

Method 'get_data_with_partial_last_batch' is abstract in class 'TestDistributionStrategyCorrectnessBase' but is not overridden
Error

Line: 90 Column: 1

              
@testing_utils.run_all_without_tensor_float_32(
    'Uses Dense layers, which call matmul')
class DistributionStrategyLstmModelCorrectnessTest(
    _DistributionStrategyRnnModelCorrectnessTest):

  def _get_layer_class(self):
    if tf.__internal__.tf2.enabled():
      if not tf.executing_eagerly():

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 34 Column: 1

                  keras_correctness_test_base
    .TestDistributionStrategyEmbeddingModelCorrectnessBase):

  def _get_layer_class(self):
    raise NotImplementedError

  def get_model(self,
                max_words=10,
                initial_weights=None,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 35 Column: 1

                  .TestDistributionStrategyEmbeddingModelCorrectnessBase):

  def _get_layer_class(self):
    raise NotImplementedError

  def get_model(self,
                max_words=10,
                initial_weights=None,
                distribution=None,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 37 Column: 1

                def _get_layer_class(self):
    raise NotImplementedError

  def get_model(self,
                max_words=10,
                initial_weights=None,
                distribution=None,
                input_shapes=None):
    del input_shapes

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 42 Column: 1

                              initial_weights=None,
                distribution=None,
                input_shapes=None):
    del input_shapes
    rnn_cls = self._get_layer_class()

    with keras_correctness_test_base.MaybeDistributionScope(distribution):
      word_ids = keras.layers.Input(
          shape=(max_words,), dtype=np.int32, name='words')

            

Reported by Pylint.

keras/preprocessing/timeseries.py
63 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Keras timeseries dataset utilities."""

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

import numpy as np
from tensorflow.python.util.tf_export import keras_export


            

Reported by Pylint.

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

Line: 18 Column: 1

              """Keras timeseries dataset utilities."""

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

import numpy as np
from tensorflow.python.util.tf_export import keras_export



            

Reported by Pylint.

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

Line: 21 Column: 1

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

import numpy as np
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.utils.timeseries_dataset_from_array',
              'keras.preprocessing.timeseries_dataset_from_array',
              v1=[])

            

Reported by Pylint.

Module 'numpy.random' has no 'RandomState' member
Error

Line: 201 Column: 11

                if shuffle:
    if seed is None:
      seed = np.random.randint(1e6)
    rng = np.random.RandomState(seed)
    rng.shuffle(start_positions)

  sequence_length = tf.cast(sequence_length, dtype=index_dtype)
  sampling_rate = tf.cast(sampling_rate, dtype=index_dtype)


            

Reported by Pylint.

Bad option value 'g-long-lambda'
Error

Line: 212 Column: 1

                # For each initial window position, generates indices of the window elements
  indices = tf.data.Dataset.zip(
      (tf.data.Dataset.range(len(start_positions)), positions_ds)).map(
          lambda i, positions: tf.range(  # pylint: disable=g-long-lambda
              positions[i],
              positions[i] + sequence_length * sampling_rate,
              sampling_rate),
          num_parallel_calls=tf.data.AUTOTUNE)


            

Reported by Pylint.

Too many arguments (10/5)
Error

Line: 27 Column: 1

              @keras_export('keras.utils.timeseries_dataset_from_array',
              'keras.preprocessing.timeseries_dataset_from_array',
              v1=[])
def timeseries_dataset_from_array(
    data,
    targets,
    sequence_length,
    sequence_stride=1,
    sampling_rate=1,

            

Reported by Pylint.

Too many local variables (18/15)
Error

Line: 27 Column: 1

              @keras_export('keras.utils.timeseries_dataset_from_array',
              'keras.preprocessing.timeseries_dataset_from_array',
              v1=[])
def timeseries_dataset_from_array(
    data,
    targets,
    sequence_length,
    sequence_stride=1,
    sampling_rate=1,

            

Reported by Pylint.

Too many branches (20/12)
Error

Line: 27 Column: 1

              @keras_export('keras.utils.timeseries_dataset_from_array',
              'keras.preprocessing.timeseries_dataset_from_array',
              v1=[])
def timeseries_dataset_from_array(
    data,
    targets,
    sequence_length,
    sequence_stride=1,
    sampling_rate=1,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 38 Column: 1

                  seed=None,
    start_index=None,
    end_index=None):
  """Creates a dataset of sliding windows over a timeseries provided as array.

  This function takes in a sequence of data-points gathered at
  equal intervals, along with time series parameters such as
  length of the sequences/windows, spacing between two sequence/windows, etc.,
  to produce batches of timeseries inputs and targets.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 145 Column: 1

                  break
  ```
  """
  if start_index:
    if start_index < 0:
      raise ValueError(f'`start_index` must be 0 or greater. Received: '
                       f'start_index={start_index}')
    if start_index >= len(data):
      raise ValueError(f'`start_index` must be lower than the length of the '

            

Reported by Pylint.

keras/layers/preprocessing/benchmarks/discretization_adapt_benchmark.py
63 issues
Unable to import 'tensorflow'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Benchmark for Keras discretization preprocessing layer's adapt method."""

import tensorflow as tf

import time

import numpy as np


            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 23 Column: 1

              
import numpy as np

import keras
from keras.layers.preprocessing import discretization

EPSILON = 0.1

tf.compat.v1.enable_v2_behavior()

            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing'
Error

Line: 24 Column: 1

              import numpy as np

import keras
from keras.layers.preprocessing import discretization

EPSILON = 0.1

tf.compat.v1.enable_v2_behavior()


            

Reported by Pylint.

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

Line: 19 Column: 1

              
import tensorflow as tf

import time

import numpy as np

import keras
from keras.layers.preprocessing import discretization

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              

def reduce_fn(state, values, epsilon=EPSILON):
  """tf.data.Dataset-friendly implementation of mean and variance."""

  state_, = state
  summary = discretization.summarize(values, epsilon)
  if np.sum(state_[:, 0]) == 0:
    return (summary,)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 34 Column: 1

              def reduce_fn(state, values, epsilon=EPSILON):
  """tf.data.Dataset-friendly implementation of mean and variance."""

  state_, = state
  summary = discretization.summarize(values, epsilon)
  if np.sum(state_[:, 0]) == 0:
    return (summary,)
  return (discretization.merge_summaries(state_, summary, epsilon),)


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 35 Column: 1

                """tf.data.Dataset-friendly implementation of mean and variance."""

  state_, = state
  summary = discretization.summarize(values, epsilon)
  if np.sum(state_[:, 0]) == 0:
    return (summary,)
  return (discretization.merge_summaries(state_, summary, epsilon),)



            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 36 Column: 1

              
  state_, = state
  summary = discretization.summarize(values, epsilon)
  if np.sum(state_[:, 0]) == 0:
    return (summary,)
  return (discretization.merge_summaries(state_, summary, epsilon),)


class BenchmarkAdapt(tf.test.Benchmark):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 37 Column: 1

                state_, = state
  summary = discretization.summarize(values, epsilon)
  if np.sum(state_[:, 0]) == 0:
    return (summary,)
  return (discretization.merge_summaries(state_, summary, epsilon),)


class BenchmarkAdapt(tf.test.Benchmark):
  """Benchmark adapt."""

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 38 Column: 1

                summary = discretization.summarize(values, epsilon)
  if np.sum(state_[:, 0]) == 0:
    return (summary,)
  return (discretization.merge_summaries(state_, summary, epsilon),)


class BenchmarkAdapt(tf.test.Benchmark):
  """Benchmark adapt."""


            

Reported by Pylint.

keras/benchmarks/keras_examples_benchmarks/cifar10_cnn_benchmark_test.py
62 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 Cifar10CNNBenchmark(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 Cifar10CNNBenchmark(tf.test.Benchmark):
  """Benchmarks for CNN using `tf.test.Benchmark`."""


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 26 Column: 1

              

class Cifar10CNNBenchmark(tf.test.Benchmark):
  """Benchmarks for CNN using `tf.test.Benchmark`."""

  def __init__(self):
    super(Cifar10CNNBenchmark, self).__init__()
    self.num_classes = 10
    (self.x_train, self.y_train), _ = tf.keras.datasets.cifar10.load_data()

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 28 Column: 1

              class Cifar10CNNBenchmark(tf.test.Benchmark):
  """Benchmarks for CNN using `tf.test.Benchmark`."""

  def __init__(self):
    super(Cifar10CNNBenchmark, self).__init__()
    self.num_classes = 10
    (self.x_train, self.y_train), _ = tf.keras.datasets.cifar10.load_data()
    self.x_train = self.x_train.astype('float32') / 255
    self.y_train = tf.keras.utils.to_categorical(self.y_train, self.num_classes)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 29 Column: 1

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

  def __init__(self):
    super(Cifar10CNNBenchmark, self).__init__()
    self.num_classes = 10
    (self.x_train, self.y_train), _ = tf.keras.datasets.cifar10.load_data()
    self.x_train = self.x_train.astype('float32') / 255
    self.y_train = tf.keras.utils.to_categorical(self.y_train, self.num_classes)
    self.epochs = 5

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 29 Column: 5

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

  def __init__(self):
    super(Cifar10CNNBenchmark, self).__init__()
    self.num_classes = 10
    (self.x_train, self.y_train), _ = tf.keras.datasets.cifar10.load_data()
    self.x_train = self.x_train.astype('float32') / 255
    self.y_train = tf.keras.utils.to_categorical(self.y_train, self.num_classes)
    self.epochs = 5

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 30 Column: 1

              
  def __init__(self):
    super(Cifar10CNNBenchmark, self).__init__()
    self.num_classes = 10
    (self.x_train, self.y_train), _ = tf.keras.datasets.cifar10.load_data()
    self.x_train = self.x_train.astype('float32') / 255
    self.y_train = tf.keras.utils.to_categorical(self.y_train, self.num_classes)
    self.epochs = 5


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 31 Column: 1

                def __init__(self):
    super(Cifar10CNNBenchmark, self).__init__()
    self.num_classes = 10
    (self.x_train, self.y_train), _ = tf.keras.datasets.cifar10.load_data()
    self.x_train = self.x_train.astype('float32') / 255
    self.y_train = tf.keras.utils.to_categorical(self.y_train, self.num_classes)
    self.epochs = 5

  def _build_model(self):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 32 Column: 1

                  super(Cifar10CNNBenchmark, self).__init__()
    self.num_classes = 10
    (self.x_train, self.y_train), _ = tf.keras.datasets.cifar10.load_data()
    self.x_train = self.x_train.astype('float32') / 255
    self.y_train = tf.keras.utils.to_categorical(self.y_train, self.num_classes)
    self.epochs = 5

  def _build_model(self):
    """Model from https://github.com/keras-team/keras/blob/master/examples/cifar10_cnn.py."""

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 33 Column: 1

                  self.num_classes = 10
    (self.x_train, self.y_train), _ = tf.keras.datasets.cifar10.load_data()
    self.x_train = self.x_train.astype('float32') / 255
    self.y_train = tf.keras.utils.to_categorical(self.y_train, self.num_classes)
    self.epochs = 5

  def _build_model(self):
    """Model from https://github.com/keras-team/keras/blob/master/examples/cifar10_cnn.py."""
    model = tf.keras.Sequential()

            

Reported by Pylint.