The following issues were found

keras/datasets/cifar100.py
17 issues
Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 24 Column: 1

              from keras import backend
from keras.datasets.cifar import load_batch
from keras.utils.data_utils import get_file
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.datasets.cifar100.load_data')
def load_data(label_mode='fine'):
  """Loads the CIFAR100 dataset.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 29 Column: 1

              
@keras_export('keras.datasets.cifar100.load_data')
def load_data(label_mode='fine'):
  """Loads the CIFAR100 dataset.

  This is a dataset of 50,000 32x32 color training images and
  10,000 test images, labeled over 100 fine-grained classes that are
  grouped into 20 coarse-grained classes. See more info at the
  [CIFAR homepage](https://www.cs.toronto.edu/~kriz/cifar.html).

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 68 Column: 1

                assert y_test.shape == (10000, 1)
  ```
  """
  if label_mode not in ['fine', 'coarse']:
    raise ValueError('`label_mode` must be one of `"fine"`, `"coarse"`. '
                     f'Received: label_mode={label_mode}.')

  dirname = 'cifar-100-python'
  origin = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 69 Column: 1

                ```
  """
  if label_mode not in ['fine', 'coarse']:
    raise ValueError('`label_mode` must be one of `"fine"`, `"coarse"`. '
                     f'Received: label_mode={label_mode}.')

  dirname = 'cifar-100-python'
  origin = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'
  path = get_file(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 72 Column: 1

                  raise ValueError('`label_mode` must be one of `"fine"`, `"coarse"`. '
                     f'Received: label_mode={label_mode}.')

  dirname = 'cifar-100-python'
  origin = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'
  path = get_file(
      dirname,
      origin=origin,
      untar=True,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 73 Column: 1

                                   f'Received: label_mode={label_mode}.')

  dirname = 'cifar-100-python'
  origin = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'
  path = get_file(
      dirname,
      origin=origin,
      untar=True,
      file_hash=

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 74 Column: 1

              
  dirname = 'cifar-100-python'
  origin = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'
  path = get_file(
      dirname,
      origin=origin,
      untar=True,
      file_hash=
      '85cd44d02ba6437773c5bbd22e183051d648de2e7d6b014e1ef29b855ba677a7')

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 81 Column: 1

                    file_hash=
      '85cd44d02ba6437773c5bbd22e183051d648de2e7d6b014e1ef29b855ba677a7')

  fpath = os.path.join(path, 'train')
  x_train, y_train = load_batch(fpath, label_key=label_mode + '_labels')

  fpath = os.path.join(path, 'test')
  x_test, y_test = load_batch(fpath, label_key=label_mode + '_labels')


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 82 Column: 1

                    '85cd44d02ba6437773c5bbd22e183051d648de2e7d6b014e1ef29b855ba677a7')

  fpath = os.path.join(path, 'train')
  x_train, y_train = load_batch(fpath, label_key=label_mode + '_labels')

  fpath = os.path.join(path, 'test')
  x_test, y_test = load_batch(fpath, label_key=label_mode + '_labels')

  y_train = np.reshape(y_train, (len(y_train), 1))

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 84 Column: 1

                fpath = os.path.join(path, 'train')
  x_train, y_train = load_batch(fpath, label_key=label_mode + '_labels')

  fpath = os.path.join(path, 'test')
  x_test, y_test = load_batch(fpath, label_key=label_mode + '_labels')

  y_train = np.reshape(y_train, (len(y_train), 1))
  y_test = np.reshape(y_test, (len(y_test), 1))


            

Reported by Pylint.

keras/benchmarks/benchmark_util_test.py
17 issues
Unable to import 'tensorflow'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for benchmark utitilies."""

import tensorflow as tf

from keras.benchmarks import benchmark_util


class BenchmarkUtilTest(tf.test.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 22 Column: 1

              from keras.benchmarks import benchmark_util


class BenchmarkUtilTest(tf.test.TestCase):

  def test_get_benchmark_name(self):
    name = "benchmark_layer_call__Conv2D_small_shape"
    expected = ["Conv2D", "small", "shape"]
    out = benchmark_util.get_benchmark_name(name)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 24 Column: 1

              
class BenchmarkUtilTest(tf.test.TestCase):

  def test_get_benchmark_name(self):
    name = "benchmark_layer_call__Conv2D_small_shape"
    expected = ["Conv2D", "small", "shape"]
    out = benchmark_util.get_benchmark_name(name)
    self.assertAllEqual(out, expected)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 3

              
class BenchmarkUtilTest(tf.test.TestCase):

  def test_get_benchmark_name(self):
    name = "benchmark_layer_call__Conv2D_small_shape"
    expected = ["Conv2D", "small", "shape"]
    out = benchmark_util.get_benchmark_name(name)
    self.assertAllEqual(out, expected)


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 25 Column: 1

              class BenchmarkUtilTest(tf.test.TestCase):

  def test_get_benchmark_name(self):
    name = "benchmark_layer_call__Conv2D_small_shape"
    expected = ["Conv2D", "small", "shape"]
    out = benchmark_util.get_benchmark_name(name)
    self.assertAllEqual(out, expected)

  def test_generate_benchmark_params_cpu_gpu(self):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 26 Column: 1

              
  def test_get_benchmark_name(self):
    name = "benchmark_layer_call__Conv2D_small_shape"
    expected = ["Conv2D", "small", "shape"]
    out = benchmark_util.get_benchmark_name(name)
    self.assertAllEqual(out, expected)

  def test_generate_benchmark_params_cpu_gpu(self):
    adam_opt = tf.keras.optimizers.Adam()

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 27 Column: 1

                def test_get_benchmark_name(self):
    name = "benchmark_layer_call__Conv2D_small_shape"
    expected = ["Conv2D", "small", "shape"]
    out = benchmark_util.get_benchmark_name(name)
    self.assertAllEqual(out, expected)

  def test_generate_benchmark_params_cpu_gpu(self):
    adam_opt = tf.keras.optimizers.Adam()
    sgd_opt = tf.keras.optimizers.SGD()

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 28 Column: 1

                  name = "benchmark_layer_call__Conv2D_small_shape"
    expected = ["Conv2D", "small", "shape"]
    out = benchmark_util.get_benchmark_name(name)
    self.assertAllEqual(out, expected)

  def test_generate_benchmark_params_cpu_gpu(self):
    adam_opt = tf.keras.optimizers.Adam()
    sgd_opt = tf.keras.optimizers.SGD()
    params = [

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 3

                  out = benchmark_util.get_benchmark_name(name)
    self.assertAllEqual(out, expected)

  def test_generate_benchmark_params_cpu_gpu(self):
    adam_opt = tf.keras.optimizers.Adam()
    sgd_opt = tf.keras.optimizers.SGD()
    params = [
        ("Adam", adam_opt, 10),
        ("SGD", sgd_opt, 10),

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

                  out = benchmark_util.get_benchmark_name(name)
    self.assertAllEqual(out, expected)

  def test_generate_benchmark_params_cpu_gpu(self):
    adam_opt = tf.keras.optimizers.Adam()
    sgd_opt = tf.keras.optimizers.SGD()
    params = [
        ("Adam", adam_opt, 10),
        ("SGD", sgd_opt, 10),

            

Reported by Pylint.

keras/saving/model_config.py
16 issues
Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 19 Column: 1

              """Functions that save the model's config into different formats."""

from keras.saving.saved_model import json_utils
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.models.model_from_config')
def model_from_config(config, custom_objects=None):
  """Instantiates a Keras model from its config.

            

Reported by Pylint.

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

Line: 51 Column: 1

                  raise TypeError('`model_from_config` expects a dictionary, not a list. '
                    f'Received: config={config}. Did you meant to use '
                    '`Sequential.from_config(config)`?')
  from keras.layers import deserialize  # pylint: disable=g-import-not-at-top
  return deserialize(config, custom_objects=custom_objects)


@keras_export('keras.models.model_from_yaml')
def model_from_yaml(yaml_string, custom_objects=None):

            

Reported by Pylint.

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

Line: 103 Column: 1

                    A Keras model instance (uncompiled).
  """
  config = json_utils.decode(json_string)
  from keras.layers import deserialize  # pylint: disable=g-import-not-at-top
  return deserialize(config, custom_objects=custom_objects)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 24 Column: 1

              
@keras_export('keras.models.model_from_config')
def model_from_config(config, custom_objects=None):
  """Instantiates a Keras model from its config.

  Usage:
  ```
  # for a Functional API model
  tf.keras.Model().from_config(model.get_config())

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 47 Column: 1

                Raises:
      TypeError: if `config` is not a dictionary.
  """
  if isinstance(config, list):
    raise TypeError('`model_from_config` expects a dictionary, not a list. '
                    f'Received: config={config}. Did you meant to use '
                    '`Sequential.from_config(config)`?')
  from keras.layers import deserialize  # pylint: disable=g-import-not-at-top
  return deserialize(config, custom_objects=custom_objects)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 48 Column: 1

                    TypeError: if `config` is not a dictionary.
  """
  if isinstance(config, list):
    raise TypeError('`model_from_config` expects a dictionary, not a list. '
                    f'Received: config={config}. Did you meant to use '
                    '`Sequential.from_config(config)`?')
  from keras.layers import deserialize  # pylint: disable=g-import-not-at-top
  return deserialize(config, custom_objects=custom_objects)


            

Reported by Pylint.

Import outside toplevel (keras.layers.deserialize)
Error

Line: 51 Column: 3

                  raise TypeError('`model_from_config` expects a dictionary, not a list. '
                    f'Received: config={config}. Did you meant to use '
                    '`Sequential.from_config(config)`?')
  from keras.layers import deserialize  # pylint: disable=g-import-not-at-top
  return deserialize(config, custom_objects=custom_objects)


@keras_export('keras.models.model_from_yaml')
def model_from_yaml(yaml_string, custom_objects=None):

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 51 Column: 1

                  raise TypeError('`model_from_config` expects a dictionary, not a list. '
                    f'Received: config={config}. Did you meant to use '
                    '`Sequential.from_config(config)`?')
  from keras.layers import deserialize  # pylint: disable=g-import-not-at-top
  return deserialize(config, custom_objects=custom_objects)


@keras_export('keras.models.model_from_yaml')
def model_from_yaml(yaml_string, custom_objects=None):

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 52 Column: 1

                                  f'Received: config={config}. Did you meant to use '
                    '`Sequential.from_config(config)`?')
  from keras.layers import deserialize  # pylint: disable=g-import-not-at-top
  return deserialize(config, custom_objects=custom_objects)


@keras_export('keras.models.model_from_yaml')
def model_from_yaml(yaml_string, custom_objects=None):
  """Parses a yaml model configuration file and returns a model instance.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 57 Column: 1

              
@keras_export('keras.models.model_from_yaml')
def model_from_yaml(yaml_string, custom_objects=None):
  """Parses a yaml model configuration file and returns a model instance.

  Note: Since TF 2.6, this method is no longer supported and will raise a
  RuntimeError.

  Args:

            

Reported by Pylint.

keras/saving/utils_v1/signature_def_utils.py
16 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""SignatureDef utility functions implementation."""

import tensorflow.compat.v2 as tf

from keras.saving.utils_v1 import unexported_constants


# LINT.IfChange

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 1

              

# LINT.IfChange
def supervised_train_signature_def(
    inputs, loss, predictions=None, metrics=None):
  return _supervised_signature_def(
      unexported_constants.SUPERVISED_TRAIN_METHOD_NAME, inputs, loss=loss,
      predictions=predictions, metrics=metrics)


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 25 Column: 1

              # LINT.IfChange
def supervised_train_signature_def(
    inputs, loss, predictions=None, metrics=None):
  return _supervised_signature_def(
      unexported_constants.SUPERVISED_TRAIN_METHOD_NAME, inputs, loss=loss,
      predictions=predictions, metrics=metrics)


def supervised_eval_signature_def(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 1

                    predictions=predictions, metrics=metrics)


def supervised_eval_signature_def(
    inputs, loss, predictions=None, metrics=None):
  return _supervised_signature_def(
      unexported_constants.SUPERVISED_EVAL_METHOD_NAME, inputs, loss=loss,
      predictions=predictions, metrics=metrics)


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              
def supervised_eval_signature_def(
    inputs, loss, predictions=None, metrics=None):
  return _supervised_signature_def(
      unexported_constants.SUPERVISED_EVAL_METHOD_NAME, inputs, loss=loss,
      predictions=predictions, metrics=metrics)


def _supervised_signature_def(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 40 Column: 1

              def _supervised_signature_def(
    method_name, inputs, loss=None, predictions=None,
    metrics=None):
  """Creates a signature for training and eval data.

  This function produces signatures that describe the inputs and outputs
  of a supervised process, such as training or evaluation, that
  results in loss, metrics, and the like. Note that this function only requires
  inputs to be not None.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 60 Column: 1

                Raises:
    ValueError: If inputs or outputs is `None`.
  """
  if inputs is None or not inputs:
    raise ValueError('f{method_name} `inputs` cannot be None or empty.')

  signature_inputs = {key: tf.compat.v1.saved_model.build_tensor_info(tensor)
                      for key, tensor in inputs.items()}


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 61 Column: 1

                  ValueError: If inputs or outputs is `None`.
  """
  if inputs is None or not inputs:
    raise ValueError('f{method_name} `inputs` cannot be None or empty.')

  signature_inputs = {key: tf.compat.v1.saved_model.build_tensor_info(tensor)
                      for key, tensor in inputs.items()}

  signature_outputs = {}

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 63 Column: 1

                if inputs is None or not inputs:
    raise ValueError('f{method_name} `inputs` cannot be None or empty.')

  signature_inputs = {key: tf.compat.v1.saved_model.build_tensor_info(tensor)
                      for key, tensor in inputs.items()}

  signature_outputs = {}
  for output_set in (loss, predictions, metrics):
    if output_set is not None:

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 66 Column: 1

                signature_inputs = {key: tf.compat.v1.saved_model.build_tensor_info(tensor)
                      for key, tensor in inputs.items()}

  signature_outputs = {}
  for output_set in (loss, predictions, metrics):
    if output_set is not None:
      sig_out = {key: tf.compat.v1.saved_model.build_tensor_info(tensor)
                 for key, tensor in output_set.items()}
      signature_outputs.update(sig_out)

            

Reported by Pylint.

keras/layers/preprocessing/hashing_distribution_test.py
16 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for keras.layers.preprocessing.hashing."""

import tensorflow.compat.v2 as tf

import numpy as np

import keras
from keras import keras_parameterized

            

Reported by Pylint.

Missing class docstring
Error

Line: 32 Column: 1

                  tf.__internal__.test.combinations.combine(
        distribution=all_strategies,
        mode=["eager", "graph"]))
class HashingDistributionTest(keras_parameterized.TestCase,
                              preprocessing_test_utils.PreprocessingLayerTest):

  def test_distribution(self, distribution):
    input_data = np.asarray([["omar"], ["stringer"], ["marlo"], ["wire"]])
    input_dataset = tf.data.Dataset.from_tensor_slices(input_data).batch(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 3

              class HashingDistributionTest(keras_parameterized.TestCase,
                              preprocessing_test_utils.PreprocessingLayerTest):

  def test_distribution(self, distribution):
    input_data = np.asarray([["omar"], ["stringer"], ["marlo"], ["wire"]])
    input_dataset = tf.data.Dataset.from_tensor_slices(input_data).batch(
        2, drop_remainder=True)
    expected_output = [[0], [0], [1], [0]]


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 35 Column: 1

              class HashingDistributionTest(keras_parameterized.TestCase,
                              preprocessing_test_utils.PreprocessingLayerTest):

  def test_distribution(self, distribution):
    input_data = np.asarray([["omar"], ["stringer"], ["marlo"], ["wire"]])
    input_dataset = tf.data.Dataset.from_tensor_slices(input_data).batch(
        2, drop_remainder=True)
    expected_output = [[0], [0], [1], [0]]


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 36 Column: 1

                                            preprocessing_test_utils.PreprocessingLayerTest):

  def test_distribution(self, distribution):
    input_data = np.asarray([["omar"], ["stringer"], ["marlo"], ["wire"]])
    input_dataset = tf.data.Dataset.from_tensor_slices(input_data).batch(
        2, drop_remainder=True)
    expected_output = [[0], [0], [1], [0]]

    tf.config.set_soft_device_placement(True)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 37 Column: 1

              
  def test_distribution(self, distribution):
    input_data = np.asarray([["omar"], ["stringer"], ["marlo"], ["wire"]])
    input_dataset = tf.data.Dataset.from_tensor_slices(input_data).batch(
        2, drop_remainder=True)
    expected_output = [[0], [0], [1], [0]]

    tf.config.set_soft_device_placement(True)


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 39 Column: 1

                  input_data = np.asarray([["omar"], ["stringer"], ["marlo"], ["wire"]])
    input_dataset = tf.data.Dataset.from_tensor_slices(input_data).batch(
        2, drop_remainder=True)
    expected_output = [[0], [0], [1], [0]]

    tf.config.set_soft_device_placement(True)

    with distribution.scope():
      input_data = keras.Input(shape=(None,), dtype=tf.string)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 41 Column: 1

                      2, drop_remainder=True)
    expected_output = [[0], [0], [1], [0]]

    tf.config.set_soft_device_placement(True)

    with distribution.scope():
      input_data = keras.Input(shape=(None,), dtype=tf.string)
      layer = hashing.Hashing(num_bins=2)
      int_data = layer(input_data)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 43 Column: 1

              
    tf.config.set_soft_device_placement(True)

    with distribution.scope():
      input_data = keras.Input(shape=(None,), dtype=tf.string)
      layer = hashing.Hashing(num_bins=2)
      int_data = layer(input_data)
      model = keras.Model(inputs=input_data, outputs=int_data)
    output_dataset = model.predict(input_dataset)

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 44 Column: 1

                  tf.config.set_soft_device_placement(True)

    with distribution.scope():
      input_data = keras.Input(shape=(None,), dtype=tf.string)
      layer = hashing.Hashing(num_bins=2)
      int_data = layer(input_data)
      model = keras.Model(inputs=input_data, outputs=int_data)
    output_dataset = model.predict(input_dataset)
    self.assertAllEqual(expected_output, output_dataset)

            

Reported by Pylint.

keras/integration_test/preprocessing_applied_in_dataset_test.py
16 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.integration_test import preprocessing_test_utils as utils

ds_combinations = tf.__internal__.distribute.combinations
multi_process_runner = tf.__internal__.distribute.multi_process_runner
test_combinations = tf.__internal__.test.combinations

            

Reported by Pylint.

Unable to import 'keras.integration_test'
Error

Line: 21 Column: 1

              from __future__ import print_function

import tensorflow as tf
from keras.integration_test import preprocessing_test_utils as utils

ds_combinations = tf.__internal__.distribute.combinations
multi_process_runner = tf.__internal__.distribute.multi_process_runner
test_combinations = tf.__internal__.test.combinations


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 45 Column: 1

              
@ds_combinations.generate(
    test_combinations.combine(strategy=STRATEGIES, mode="eager"))
class PreprocessingAppliedInDatasetTest(tf.test.TestCase):
  """Demonstrate Keras preprocessing layers applied in tf.data.Dataset.map."""

  def testDistributedModelFit(self, strategy):
    with strategy.scope():
      preprocessing_model = utils.make_preprocessing_model(self.get_temp_dir())

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 46 Column: 1

              @ds_combinations.generate(
    test_combinations.combine(strategy=STRATEGIES, mode="eager"))
class PreprocessingAppliedInDatasetTest(tf.test.TestCase):
  """Demonstrate Keras preprocessing layers applied in tf.data.Dataset.map."""

  def testDistributedModelFit(self, strategy):
    with strategy.scope():
      preprocessing_model = utils.make_preprocessing_model(self.get_temp_dir())
      training_model = utils.make_training_model()

            

Reported by Pylint.

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

Line: 48 Column: 3

              class PreprocessingAppliedInDatasetTest(tf.test.TestCase):
  """Demonstrate Keras preprocessing layers applied in tf.data.Dataset.map."""

  def testDistributedModelFit(self, strategy):
    with strategy.scope():
      preprocessing_model = utils.make_preprocessing_model(self.get_temp_dir())
      training_model = utils.make_training_model()
      training_model.compile(optimizer="sgd", loss="binary_crossentropy")


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 48 Column: 1

              class PreprocessingAppliedInDatasetTest(tf.test.TestCase):
  """Demonstrate Keras preprocessing layers applied in tf.data.Dataset.map."""

  def testDistributedModelFit(self, strategy):
    with strategy.scope():
      preprocessing_model = utils.make_preprocessing_model(self.get_temp_dir())
      training_model = utils.make_training_model()
      training_model.compile(optimizer="sgd", loss="binary_crossentropy")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 48 Column: 3

              class PreprocessingAppliedInDatasetTest(tf.test.TestCase):
  """Demonstrate Keras preprocessing layers applied in tf.data.Dataset.map."""

  def testDistributedModelFit(self, strategy):
    with strategy.scope():
      preprocessing_model = utils.make_preprocessing_model(self.get_temp_dir())
      training_model = utils.make_training_model()
      training_model.compile(optimizer="sgd", loss="binary_crossentropy")


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 49 Column: 1

                """Demonstrate Keras preprocessing layers applied in tf.data.Dataset.map."""

  def testDistributedModelFit(self, strategy):
    with strategy.scope():
      preprocessing_model = utils.make_preprocessing_model(self.get_temp_dir())
      training_model = utils.make_training_model()
      training_model.compile(optimizer="sgd", loss="binary_crossentropy")

    dataset = utils.make_dataset()

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 50 Column: 1

              
  def testDistributedModelFit(self, strategy):
    with strategy.scope():
      preprocessing_model = utils.make_preprocessing_model(self.get_temp_dir())
      training_model = utils.make_training_model()
      training_model.compile(optimizer="sgd", loss="binary_crossentropy")

    dataset = utils.make_dataset()
    dataset = dataset.batch(utils.BATCH_SIZE)

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 51 Column: 1

                def testDistributedModelFit(self, strategy):
    with strategy.scope():
      preprocessing_model = utils.make_preprocessing_model(self.get_temp_dir())
      training_model = utils.make_training_model()
      training_model.compile(optimizer="sgd", loss="binary_crossentropy")

    dataset = utils.make_dataset()
    dataset = dataset.batch(utils.BATCH_SIZE)
    dataset = dataset.map(lambda x, y: (preprocessing_model(x), y))

            

Reported by Pylint.

keras/layers/layers_test.py
15 issues
Bad option value 'g-classes-have-attributes'
Error

Line: 15 Column: 1

              # See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# pylint: disable=g-classes-have-attributes
"""Tests for layers.__init__."""

import tensorflow.compat.v2 as tf
from keras import layers


            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 18 Column: 1

              # pylint: disable=g-classes-have-attributes
"""Tests for layers.__init__."""

import tensorflow.compat.v2 as tf
from keras import layers


class LayersTest(tf.test.TestCase):


            

Reported by Pylint.

Access to a protected member _USE_V2_BEHAVIOR of a client class
Error

Line: 28 Column: 23

                  if tf.__internal__.tf2.enabled():
      normalization_parent = layers.Normalization.__module__.split('.')[-1]
      self.assertEqual('normalization', normalization_parent)
      self.assertTrue(layers.BatchNormalization._USE_V2_BEHAVIOR)
    else:
      self.assertFalse(layers.BatchNormalization._USE_V2_BEHAVIOR)


if __name__ == '__main__':

            

Reported by Pylint.

Access to a protected member _USE_V2_BEHAVIOR of a client class
Error

Line: 30 Column: 24

                    self.assertEqual('normalization', normalization_parent)
      self.assertTrue(layers.BatchNormalization._USE_V2_BEHAVIOR)
    else:
      self.assertFalse(layers.BatchNormalization._USE_V2_BEHAVIOR)


if __name__ == '__main__':
  tf.test.main()

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 22 Column: 1

              from keras import layers


class LayersTest(tf.test.TestCase):

  def test_keras_private_symbol(self):
    if tf.__internal__.tf2.enabled():
      normalization_parent = layers.Normalization.__module__.split('.')[-1]
      self.assertEqual('normalization', normalization_parent)

            

Reported by Pylint.

Missing class docstring
Error

Line: 22 Column: 1

              from keras import layers


class LayersTest(tf.test.TestCase):

  def test_keras_private_symbol(self):
    if tf.__internal__.tf2.enabled():
      normalization_parent = layers.Normalization.__module__.split('.')[-1]
      self.assertEqual('normalization', normalization_parent)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 3

              
class LayersTest(tf.test.TestCase):

  def test_keras_private_symbol(self):
    if tf.__internal__.tf2.enabled():
      normalization_parent = layers.Normalization.__module__.split('.')[-1]
      self.assertEqual('normalization', normalization_parent)
      self.assertTrue(layers.BatchNormalization._USE_V2_BEHAVIOR)
    else:

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 24 Column: 1

              
class LayersTest(tf.test.TestCase):

  def test_keras_private_symbol(self):
    if tf.__internal__.tf2.enabled():
      normalization_parent = layers.Normalization.__module__.split('.')[-1]
      self.assertEqual('normalization', normalization_parent)
      self.assertTrue(layers.BatchNormalization._USE_V2_BEHAVIOR)
    else:

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 25 Column: 1

              class LayersTest(tf.test.TestCase):

  def test_keras_private_symbol(self):
    if tf.__internal__.tf2.enabled():
      normalization_parent = layers.Normalization.__module__.split('.')[-1]
      self.assertEqual('normalization', normalization_parent)
      self.assertTrue(layers.BatchNormalization._USE_V2_BEHAVIOR)
    else:
      self.assertFalse(layers.BatchNormalization._USE_V2_BEHAVIOR)

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 26 Column: 1

              
  def test_keras_private_symbol(self):
    if tf.__internal__.tf2.enabled():
      normalization_parent = layers.Normalization.__module__.split('.')[-1]
      self.assertEqual('normalization', normalization_parent)
      self.assertTrue(layers.BatchNormalization._USE_V2_BEHAVIOR)
    else:
      self.assertFalse(layers.BatchNormalization._USE_V2_BEHAVIOR)


            

Reported by Pylint.

keras/datasets/cifar.py
15 issues
Bad indentation. Found 2 spaces, expected 4
Style

Line: 21 Column: 1

              

def load_batch(fpath, label_key='labels'):
  """Internal utility for parsing CIFAR data.

  Args:
      fpath: path the file to parse.
      label_key: key for label data in the retrieve
          dictionary.

            

Reported by Pylint.

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

Line: 31 Column: 29

                Returns:
      A tuple `(data, labels)`.
  """
  with open(fpath, 'rb') as f:
    d = cPickle.load(f, encoding='bytes')
    # decode utf8
    d_decoded = {}
    for k, v in d.items():
      d_decoded[k.decode('utf8')] = v

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 31 Column: 1

                Returns:
      A tuple `(data, labels)`.
  """
  with open(fpath, 'rb') as f:
    d = cPickle.load(f, encoding='bytes')
    # decode utf8
    d_decoded = {}
    for k, v in d.items():
      d_decoded[k.decode('utf8')] = v

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 32 Column: 1

                    A tuple `(data, labels)`.
  """
  with open(fpath, 'rb') as f:
    d = cPickle.load(f, encoding='bytes')
    # decode utf8
    d_decoded = {}
    for k, v in d.items():
      d_decoded[k.decode('utf8')] = v
    d = d_decoded

            

Reported by Pylint.

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

Line: 32 Column: 5

                    A tuple `(data, labels)`.
  """
  with open(fpath, 'rb') as f:
    d = cPickle.load(f, encoding='bytes')
    # decode utf8
    d_decoded = {}
    for k, v in d.items():
      d_decoded[k.decode('utf8')] = v
    d = d_decoded

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 34 Column: 1

                with open(fpath, 'rb') as f:
    d = cPickle.load(f, encoding='bytes')
    # decode utf8
    d_decoded = {}
    for k, v in d.items():
      d_decoded[k.decode('utf8')] = v
    d = d_decoded
  data = d['data']
  labels = d[label_key]

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 35 Column: 1

                  d = cPickle.load(f, encoding='bytes')
    # decode utf8
    d_decoded = {}
    for k, v in d.items():
      d_decoded[k.decode('utf8')] = v
    d = d_decoded
  data = d['data']
  labels = d[label_key]


            

Reported by Pylint.

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

Line: 35 Column: 12

                  d = cPickle.load(f, encoding='bytes')
    # decode utf8
    d_decoded = {}
    for k, v in d.items():
      d_decoded[k.decode('utf8')] = v
    d = d_decoded
  data = d['data']
  labels = d[label_key]


            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 36 Column: 1

                  # decode utf8
    d_decoded = {}
    for k, v in d.items():
      d_decoded[k.decode('utf8')] = v
    d = d_decoded
  data = d['data']
  labels = d[label_key]

  data = data.reshape(data.shape[0], 3, 32, 32)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 37 Column: 1

                  d_decoded = {}
    for k, v in d.items():
      d_decoded[k.decode('utf8')] = v
    d = d_decoded
  data = d['data']
  labels = d[label_key]

  data = data.reshape(data.shape[0], 3, 32, 32)
  return data, labels

            

Reported by Pylint.

keras/utils/np_utils_test.py
15 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for np_utils."""

import tensorflow.compat.v2 as tf

import numpy as np

from keras.utils import np_utils


            

Reported by Pylint.

Missing class docstring
Error

Line: 24 Column: 1

              from keras.utils import np_utils


class TestNPUtils(tf.test.TestCase):

  def test_to_categorical(self):
    num_classes = 5
    shapes = [(1,), (3,), (4, 3), (5, 4, 3), (3, 1), (3, 2, 1)]
    expected_shapes = [(1, num_classes), (3, num_classes), (4, 3, num_classes),

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 24 Column: 1

              from keras.utils import np_utils


class TestNPUtils(tf.test.TestCase):

  def test_to_categorical(self):
    num_classes = 5
    shapes = [(1,), (3,), (4, 3), (5, 4, 3), (3, 1), (3, 2, 1)]
    expected_shapes = [(1, num_classes), (3, num_classes), (4, 3, num_classes),

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 26 Column: 1

              
class TestNPUtils(tf.test.TestCase):

  def test_to_categorical(self):
    num_classes = 5
    shapes = [(1,), (3,), (4, 3), (5, 4, 3), (3, 1), (3, 2, 1)]
    expected_shapes = [(1, num_classes), (3, num_classes), (4, 3, num_classes),
                       (5, 4, 3, num_classes), (3, num_classes),
                       (3, 2, num_classes)]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 3

              
class TestNPUtils(tf.test.TestCase):

  def test_to_categorical(self):
    num_classes = 5
    shapes = [(1,), (3,), (4, 3), (5, 4, 3), (3, 1), (3, 2, 1)]
    expected_shapes = [(1, num_classes), (3, num_classes), (4, 3, num_classes),
                       (5, 4, 3, num_classes), (3, num_classes),
                       (3, 2, num_classes)]

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 27 Column: 1

              class TestNPUtils(tf.test.TestCase):

  def test_to_categorical(self):
    num_classes = 5
    shapes = [(1,), (3,), (4, 3), (5, 4, 3), (3, 1), (3, 2, 1)]
    expected_shapes = [(1, num_classes), (3, num_classes), (4, 3, num_classes),
                       (5, 4, 3, num_classes), (3, num_classes),
                       (3, 2, num_classes)]
    labels = [np.random.randint(0, num_classes, shape) for shape in shapes]

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 28 Column: 1

              
  def test_to_categorical(self):
    num_classes = 5
    shapes = [(1,), (3,), (4, 3), (5, 4, 3), (3, 1), (3, 2, 1)]
    expected_shapes = [(1, num_classes), (3, num_classes), (4, 3, num_classes),
                       (5, 4, 3, num_classes), (3, num_classes),
                       (3, 2, num_classes)]
    labels = [np.random.randint(0, num_classes, shape) for shape in shapes]
    one_hots = [

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 29 Column: 1

                def test_to_categorical(self):
    num_classes = 5
    shapes = [(1,), (3,), (4, 3), (5, 4, 3), (3, 1), (3, 2, 1)]
    expected_shapes = [(1, num_classes), (3, num_classes), (4, 3, num_classes),
                       (5, 4, 3, num_classes), (3, num_classes),
                       (3, 2, num_classes)]
    labels = [np.random.randint(0, num_classes, shape) for shape in shapes]
    one_hots = [
        np_utils.to_categorical(label, num_classes) for label in labels]

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 32 Column: 1

                  expected_shapes = [(1, num_classes), (3, num_classes), (4, 3, num_classes),
                       (5, 4, 3, num_classes), (3, num_classes),
                       (3, 2, num_classes)]
    labels = [np.random.randint(0, num_classes, shape) for shape in shapes]
    one_hots = [
        np_utils.to_categorical(label, num_classes) for label in labels]
    for label, one_hot, expected_shape in zip(labels,
                                              one_hots,
                                              expected_shapes):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 33 Column: 1

                                     (5, 4, 3, num_classes), (3, num_classes),
                       (3, 2, num_classes)]
    labels = [np.random.randint(0, num_classes, shape) for shape in shapes]
    one_hots = [
        np_utils.to_categorical(label, num_classes) for label in labels]
    for label, one_hot, expected_shape in zip(labels,
                                              one_hots,
                                              expected_shapes):
      # Check shape

            

Reported by Pylint.

keras/utils/io_utils.py
13 issues
Bad option value 'g-import-not-at-top'
Error

Line: 15 Column: 1

              # See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# pylint: disable=g-import-not-at-top
"""Utilities related to disk I/O."""

import os



            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 22 Column: 1

              

def path_to_string(path):
  """Convert `PathLike` objects to their string representation.

  If given a non-string typed path object, converts it to its string
  representation.

  If the object passed to `path` is not among the above, then it is

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 37 Column: 1

                Returns:
    A string representation of the path argument, if Python support exists.
  """
  if isinstance(path, os.PathLike):
    return os.fspath(path)
  return path


def ask_to_proceed_with_overwrite(filepath):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 38 Column: 1

                  A string representation of the path argument, if Python support exists.
  """
  if isinstance(path, os.PathLike):
    return os.fspath(path)
  return path


def ask_to_proceed_with_overwrite(filepath):
  """Produces a prompt asking about overwriting a file.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 39 Column: 1

                """
  if isinstance(path, os.PathLike):
    return os.fspath(path)
  return path


def ask_to_proceed_with_overwrite(filepath):
  """Produces a prompt asking about overwriting a file.


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 43 Column: 1

              

def ask_to_proceed_with_overwrite(filepath):
  """Produces a prompt asking about overwriting a file.

  Args:
      filepath: the path to the file to be overwritten.

  Returns:

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 51 Column: 1

                Returns:
      True if we can proceed with overwrite, False otherwise.
  """
  overwrite = input('[WARNING] %s already exists - overwrite? '
                    '[y/n]' % (filepath)).strip().lower()
  while overwrite not in ('y', 'n'):
    overwrite = input('Enter "y" (overwrite) or "n" '
                      '(cancel).').strip().lower()
  if overwrite == 'n':

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 53 Column: 1

                """
  overwrite = input('[WARNING] %s already exists - overwrite? '
                    '[y/n]' % (filepath)).strip().lower()
  while overwrite not in ('y', 'n'):
    overwrite = input('Enter "y" (overwrite) or "n" '
                      '(cancel).').strip().lower()
  if overwrite == 'n':
    return False
  print('[TIP] Next time specify overwrite=True!')

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 54 Column: 1

                overwrite = input('[WARNING] %s already exists - overwrite? '
                    '[y/n]' % (filepath)).strip().lower()
  while overwrite not in ('y', 'n'):
    overwrite = input('Enter "y" (overwrite) or "n" '
                      '(cancel).').strip().lower()
  if overwrite == 'n':
    return False
  print('[TIP] Next time specify overwrite=True!')
  return True

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 56 Column: 1

                while overwrite not in ('y', 'n'):
    overwrite = input('Enter "y" (overwrite) or "n" '
                      '(cancel).').strip().lower()
  if overwrite == 'n':
    return False
  print('[TIP] Next time specify overwrite=True!')
  return True

            

Reported by Pylint.