The following issues were found

keras/integration_test/module_test.py
37 issues
Unable to import 'tensorflow'
Error

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================

import tensorflow as tf


class ModuleTest(tf.test.TestCase):

  def test_module_discover_layer_variable(self):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Copyright 2020 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: 19 Column: 1

              import tensorflow as tf


class ModuleTest(tf.test.TestCase):

  def test_module_discover_layer_variable(self):
    m = tf.Module()
    m.a = tf.keras.layers.Dense(1)
    m.b = tf.keras.layers.Dense(2)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 3

              
class ModuleTest(tf.test.TestCase):

  def test_module_discover_layer_variable(self):
    m = tf.Module()
    m.a = tf.keras.layers.Dense(1)
    m.b = tf.keras.layers.Dense(2)

    # The weights of the layer has not been created yet.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 21 Column: 1

              
class ModuleTest(tf.test.TestCase):

  def test_module_discover_layer_variable(self):
    m = tf.Module()
    m.a = tf.keras.layers.Dense(1)
    m.b = tf.keras.layers.Dense(2)

    # The weights of the layer has not been created yet.

            

Reported by Pylint.

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

Line: 22 Column: 5

              class ModuleTest(tf.test.TestCase):

  def test_module_discover_layer_variable(self):
    m = tf.Module()
    m.a = tf.keras.layers.Dense(1)
    m.b = tf.keras.layers.Dense(2)

    # The weights of the layer has not been created yet.
    self.assertEmpty(m.variables)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 22 Column: 1

              class ModuleTest(tf.test.TestCase):

  def test_module_discover_layer_variable(self):
    m = tf.Module()
    m.a = tf.keras.layers.Dense(1)
    m.b = tf.keras.layers.Dense(2)

    # The weights of the layer has not been created yet.
    self.assertEmpty(m.variables)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 23 Column: 1

              
  def test_module_discover_layer_variable(self):
    m = tf.Module()
    m.a = tf.keras.layers.Dense(1)
    m.b = tf.keras.layers.Dense(2)

    # The weights of the layer has not been created yet.
    self.assertEmpty(m.variables)
    self.assertLen(m.submodules, 2)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 24 Column: 1

                def test_module_discover_layer_variable(self):
    m = tf.Module()
    m.a = tf.keras.layers.Dense(1)
    m.b = tf.keras.layers.Dense(2)

    # The weights of the layer has not been created yet.
    self.assertEmpty(m.variables)
    self.assertLen(m.submodules, 2)


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 27 Column: 1

                  m.b = tf.keras.layers.Dense(2)

    # The weights of the layer has not been created yet.
    self.assertEmpty(m.variables)
    self.assertLen(m.submodules, 2)

    inputs = tf.keras.layers.Input((1,))
    m.a(inputs)
    m.b(inputs)

            

Reported by Pylint.

keras/tools/pip_package/create_pip_helper.py
36 issues
Missing class docstring
Error

Line: 47 Column: 1

              ])


class PipPackagingError(Exception):
  pass


def create_init_files(pip_root):
  """Create __init__.py in pip directory tree.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 48 Column: 1

              

class PipPackagingError(Exception):
  pass


def create_init_files(pip_root):
  """Create __init__.py in pip directory tree.


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 52 Column: 1

              

def create_init_files(pip_root):
  """Create __init__.py in pip directory tree.

  These files are auto-generated by Bazel when doing typical build/test, but
  do not get auto-generated by the pip build process. Currently, the entire
  directory tree is just python files, so its fine to just create all of the
  init files.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 62 Column: 1

                Args:
    pip_root: Root directory of code being packaged into pip.
  """
  for path, subdirs, _ in os.walk(pip_root):
    for subdir in subdirs:
      init_file_path = os.path.join(path, subdir, '__init__.py')
      if any(excluded_path in init_file_path
             for excluded_path in EXCLUDED_INIT_FILE_DIRECTORIES):
        continue

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 63 Column: 1

                  pip_root: Root directory of code being packaged into pip.
  """
  for path, subdirs, _ in os.walk(pip_root):
    for subdir in subdirs:
      init_file_path = os.path.join(path, subdir, '__init__.py')
      if any(excluded_path in init_file_path
             for excluded_path in EXCLUDED_INIT_FILE_DIRECTORIES):
        continue
      if not os.path.exists(init_file_path):

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 64 Column: 1

                """
  for path, subdirs, _ in os.walk(pip_root):
    for subdir in subdirs:
      init_file_path = os.path.join(path, subdir, '__init__.py')
      if any(excluded_path in init_file_path
             for excluded_path in EXCLUDED_INIT_FILE_DIRECTORIES):
        continue
      if not os.path.exists(init_file_path):
        # Create empty file

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 65 Column: 1

                for path, subdirs, _ in os.walk(pip_root):
    for subdir in subdirs:
      init_file_path = os.path.join(path, subdir, '__init__.py')
      if any(excluded_path in init_file_path
             for excluded_path in EXCLUDED_INIT_FILE_DIRECTORIES):
        continue
      if not os.path.exists(init_file_path):
        # Create empty file
        open(init_file_path, 'w').close()

            

Reported by Pylint.

Bad indentation. Found 8 spaces, expected 16
Style

Line: 67 Column: 1

                    init_file_path = os.path.join(path, subdir, '__init__.py')
      if any(excluded_path in init_file_path
             for excluded_path in EXCLUDED_INIT_FILE_DIRECTORIES):
        continue
      if not os.path.exists(init_file_path):
        # Create empty file
        open(init_file_path, 'w').close()



            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 68 Column: 1

                    if any(excluded_path in init_file_path
             for excluded_path in EXCLUDED_INIT_FILE_DIRECTORIES):
        continue
      if not os.path.exists(init_file_path):
        # Create empty file
        open(init_file_path, 'w').close()


def verify_python_files_in_pip(pip_root, bazel_root):

            

Reported by Pylint.

Bad indentation. Found 8 spaces, expected 16
Style

Line: 70 Column: 1

                      continue
      if not os.path.exists(init_file_path):
        # Create empty file
        open(init_file_path, 'w').close()


def verify_python_files_in_pip(pip_root, bazel_root):
  """Verifies all expected files are packaged into Pip.


            

Reported by Pylint.

keras/layers/preprocessing/benchmarks/category_cross_hash_dense_benchmark.py
36 issues
Unable to import 'tensorflow'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Benchmark for KPL implementation of categorical cross hash columns with dense inputs."""

import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_crossing
from keras.layers.preprocessing import hashing

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 19 Column: 1

              
import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_crossing
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm


            

Reported by Pylint.

Unable to import 'tensorflow.python.eager.def_function'
Error

Line: 20 Column: 1

              import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_crossing
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.

            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing'
Error

Line: 21 Column: 1

              
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_crossing
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()

            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing'
Error

Line: 22 Column: 1

              import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_crossing
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()


            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing.benchmarks'
Error

Line: 23 Column: 1

              from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_crossing
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()

NUM_REPEATS = 10

            

Reported by Pylint.

Too many local variables (17/15)
Error

Line: 32 Column: 1

              BATCH_SIZES = [32, 256]


def embedding_varlen(batch_size, max_length):
  """Benchmark a variable-length embedding."""
  # Data and constants.

  num_buckets = 10000
  vocab = fc_bm.create_vocabulary(32768)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 33 Column: 1

              

def embedding_varlen(batch_size, max_length):
  """Benchmark a variable-length embedding."""
  # Data and constants.

  num_buckets = 10000
  vocab = fc_bm.create_vocabulary(32768)
  data_a = fc_bm.create_string_data(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 36 Column: 1

                """Benchmark a variable-length embedding."""
  # Data and constants.

  num_buckets = 10000
  vocab = fc_bm.create_vocabulary(32768)
  data_a = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
  data_b = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 37 Column: 1

                # Data and constants.

  num_buckets = 10000
  vocab = fc_bm.create_vocabulary(32768)
  data_a = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
  data_b = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)


            

Reported by Pylint.

keras/distribute/keras_stateful_lstm_model_correctness_test.py
36 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for stateful tf.keras LSTM models using DistributionStrategy."""

import tensorflow.compat.v2 as tf

import numpy as np

import keras
from keras.distribute import keras_correctness_test_base

            

Reported by Pylint.

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

Line: 42 Column: 1

                    use_validation_data=False))


class DistributionStrategyStatefulLstmModelCorrectnessTest(
    keras_correctness_test_base
    .TestDistributionStrategyEmbeddingModelCorrectnessBase):

  def get_model(self,
                max_words=10,

            

Reported by Pylint.

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

Line: 42 Column: 1

                    use_validation_data=False))


class DistributionStrategyStatefulLstmModelCorrectnessTest(
    keras_correctness_test_base
    .TestDistributionStrategyEmbeddingModelCorrectnessBase):

  def get_model(self,
                max_words=10,

            

Reported by Pylint.

Parameters differ from overridden 'get_model' method
Error

Line: 46 Column: 3

                  keras_correctness_test_base
    .TestDistributionStrategyEmbeddingModelCorrectnessBase):

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

            

Reported by Pylint.

Access to a protected member _GLOBAL_BATCH_SIZE of a client class
Error

Line: 52 Column: 18

                              distribution=None,
                input_shapes=None):
    del input_shapes
    batch_size = keras_correctness_test_base._GLOBAL_BATCH_SIZE

    with keras_correctness_test_base.MaybeDistributionScope(distribution):
      word_ids = keras.layers.Input(
          shape=(max_words,),
          batch_size=batch_size,

            

Reported by Pylint.

TODO(jhseu): Disabled to fix b/130808953. Need to investigate why it
Error

Line: 79 Column: 3

                        metrics=['sparse_categorical_accuracy'])
    return model

  # TODO(jhseu): Disabled to fix b/130808953. Need to investigate why it
  # doesn't work and enable for DistributionStrategy more generally.
  @tf.__internal__.distribute.combinations.generate(test_combinations_for_stateful_embedding_model())
  def disabled_test_stateful_lstm_model_correctness(
      self, distribution, use_numpy, use_validation_data):
    self.run_correctness_test(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 27 Column: 1

              

def strategies_for_stateful_embedding_model():
  """Returns TPUStrategy with single core device assignment."""

  return [
      tf.__internal__.distribute.combinations.tpu_strategy_one_core,
  ]


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 29 Column: 1

              def strategies_for_stateful_embedding_model():
  """Returns TPUStrategy with single core device assignment."""

  return [
      tf.__internal__.distribute.combinations.tpu_strategy_one_core,
  ]


def test_combinations_for_stateful_embedding_model():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 1

                ]


def test_combinations_for_stateful_embedding_model():
  return (tf.__internal__.test.combinations.combine(
      distribution=strategies_for_stateful_embedding_model(),
      mode='graph',
      use_numpy=False,
      use_validation_data=False))

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 35 Column: 1

              

def test_combinations_for_stateful_embedding_model():
  return (tf.__internal__.test.combinations.combine(
      distribution=strategies_for_stateful_embedding_model(),
      mode='graph',
      use_numpy=False,
      use_validation_data=False))


            

Reported by Pylint.

keras/distribute/worker_training_state.py
35 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Training state management."""

import tensorflow.compat.v2 as tf

import os
from keras import backend
from keras.distribute import distributed_file_utils
from keras.utils import mode_keys

            

Reported by Pylint.

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

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

import os
from keras import backend
from keras.distribute import distributed_file_utils
from keras.utils import mode_keys

# Constant for `tf.keras.Model` attribute to store the epoch at which the most

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              

class WorkerTrainingState:
  """Training state management class.

  This class provides apis for backing up and restoring the training state.
  This allows model and epoch information to be saved periodically and restore
  for fault-tolerance, also known as preemption-recovery purpose.
  """

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 39 Column: 1

                for fault-tolerance, also known as preemption-recovery purpose.
  """

  def __init__(self, model, checkpoint_dir):
    self._model = model

    # The epoch at which the checkpoint is saved. Used for fault-tolerance.
    # GPU device only has int64 dtype registered VarHandleOp.
    self._ckpt_saved_epoch = tf.Variable(

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 40 Column: 1

                """

  def __init__(self, model, checkpoint_dir):
    self._model = model

    # The epoch at which the checkpoint is saved. Used for fault-tolerance.
    # GPU device only has int64 dtype registered VarHandleOp.
    self._ckpt_saved_epoch = tf.Variable(
        initial_value=tf.constant(

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 44 Column: 1

              
    # The epoch at which the checkpoint is saved. Used for fault-tolerance.
    # GPU device only has int64 dtype registered VarHandleOp.
    self._ckpt_saved_epoch = tf.Variable(
        initial_value=tf.constant(
            CKPT_SAVED_EPOCH_UNUSED_VALUE, dtype=tf.int64),
        name='ckpt_saved_epoch')

    # Variable initialization.

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 50 Column: 1

                      name='ckpt_saved_epoch')

    # Variable initialization.
    backend.set_value(self._ckpt_saved_epoch, CKPT_SAVED_EPOCH_UNUSED_VALUE)

    # _ckpt_saved_epoch gets tracked and is included in the checkpoint file
    # when backing up.
    checkpoint = tf.train.Checkpoint(
        model=self._model, ckpt_saved_epoch=self._ckpt_saved_epoch,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 54 Column: 1

              
    # _ckpt_saved_epoch gets tracked and is included in the checkpoint file
    # when backing up.
    checkpoint = tf.train.Checkpoint(
        model=self._model, ckpt_saved_epoch=self._ckpt_saved_epoch,
        train_counter=self._model._train_counter)

    # If this is single-worker training, checkpoint_dir are the same for
    # write_checkpoint_manager and read_checkpoint_manager.

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 69 Column: 1

                  # workers need to perform `save()`.
    # But all workers should restore from the same checkpoint_dir as passed in
    # read_checkpoint_manager.
    self.read_checkpoint_manager = tf.train.CheckpointManager(
        checkpoint,
        directory=os.path.join(checkpoint_dir, 'chief'),
        max_to_keep=1)
    write_checkpoint_dir = distributed_file_utils.write_dirpath(
        checkpoint_dir, self._model.distribute_strategy)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 73 Column: 1

                      checkpoint,
        directory=os.path.join(checkpoint_dir, 'chief'),
        max_to_keep=1)
    write_checkpoint_dir = distributed_file_utils.write_dirpath(
        checkpoint_dir, self._model.distribute_strategy)
    if self._model.distribute_strategy.extended.should_checkpoint:
      self.write_checkpoint_manager = self.read_checkpoint_manager
    else:
      self.write_checkpoint_manager = tf.train.CheckpointManager(

            

Reported by Pylint.

keras/feature_column/dense_features_v2.py
35 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 21 Column: 1

              from __future__ import division
from __future__ import print_function

import tensorflow.compat.v2 as tf
from keras.feature_column import base_feature_layer as kfc
from keras.feature_column import dense_features
from keras.utils import tf_contextlib
from tensorflow.python.util.tf_export import keras_export


            

Reported by Pylint.

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

Line: 25 Column: 1

              from keras.feature_column import base_feature_layer as kfc
from keras.feature_column import dense_features
from keras.utils import tf_contextlib
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.layers.DenseFeatures', v1=[])
class DenseFeatures(dense_features.DenseFeatures):
  """A layer that produces a dense `Tensor` based on given `feature_columns`.

            

Reported by Pylint.

Context manager 'generator' doesn't implement __enter__ and __exit__.
Error

Line: 115 Column: 5

              
    # We explicitly track these variables since `name` is not guaranteed to be
    # unique and disable manual tracking that the add_weight call does.
    with no_manual_dependency_tracking_scope(self._layer):
      var = self._layer.add_weight(
          name=name,
          shape=shape,
          dtype=dtype,
          initializer=initializer,

            

Reported by Pylint.

Method '_output_shape' is abstract in class '_BaseFeaturesLayer' but is not overridden
Error

Line: 29 Column: 1

              

@keras_export('keras.layers.DenseFeatures', v1=[])
class DenseFeatures(dense_features.DenseFeatures):
  """A layer that produces a dense `Tensor` based on given `feature_columns`.

  Generally a single example in training data is described with FeatureColumns.
  At the first layer of the model, this column oriented data should be converted
  to a single `Tensor`.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              
@keras_export('keras.layers.DenseFeatures', v1=[])
class DenseFeatures(dense_features.DenseFeatures):
  """A layer that produces a dense `Tensor` based on given `feature_columns`.

  Generally a single example in training data is described with FeatureColumns.
  At the first layer of the model, this column oriented data should be converted
  to a single `Tensor`.


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 61 Column: 1

                ```
  """

  def __init__(self,
               feature_columns,
               trainable=True,
               name=None,
               **kwargs):
    """Creates a DenseFeatures object.

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 66 Column: 1

                             trainable=True,
               name=None,
               **kwargs):
    """Creates a DenseFeatures object.

    Args:
      feature_columns: An iterable containing the FeatureColumns to use as
        inputs to your model. All items should be instances of classes derived
        from `DenseColumn` such as `numeric_column`, `embedding_column`,

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 83 Column: 5

                  Raises:
      ValueError: if an item in `feature_columns` is not a `DenseColumn`.
    """
    super(DenseFeatures, self).__init__(
        feature_columns=feature_columns,
        trainable=trainable,
        name=name,
        **kwargs)
    self._state_manager = _StateManagerImplV2(self, self.trainable)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 83 Column: 1

                  Raises:
      ValueError: if an item in `feature_columns` is not a `DenseColumn`.
    """
    super(DenseFeatures, self).__init__(
        feature_columns=feature_columns,
        trainable=trainable,
        name=name,
        **kwargs)
    self._state_manager = _StateManagerImplV2(self, self.trainable)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 88 Column: 1

                      trainable=trainable,
        name=name,
        **kwargs)
    self._state_manager = _StateManagerImplV2(self, self.trainable)

  def build(self, _):
    for column in self._feature_columns:
      with tf.name_scope(column.name):
        column.create_state(self._state_manager)

            

Reported by Pylint.

keras/tests/serialization_util_test.py
35 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for serialization functions."""

import tensorflow.compat.v2 as tf

import json
from keras import combinations
from keras import keras_parameterized
from keras.engine import input_layer

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf

import json
from keras import combinations
from keras import keras_parameterized
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 21 Column: 1

              
import json
from keras import combinations
from keras import keras_parameterized
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.saving.saved_model import json_utils

            

Reported by Pylint.

Unable to import 'keras.engine'
Error

Line: 22 Column: 1

              import json
from keras import combinations
from keras import keras_parameterized
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.saving.saved_model import json_utils


            

Reported by Pylint.

Unable to import 'keras.engine'
Error

Line: 23 Column: 1

              from keras import combinations
from keras import keras_parameterized
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.saving.saved_model import json_utils



            

Reported by Pylint.

Unable to import 'keras.engine'
Error

Line: 24 Column: 1

              from keras import keras_parameterized
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.saving.saved_model import json_utils


@combinations.generate(combinations.combine(mode=["graph", "eager"]))

            

Reported by Pylint.

Unable to import 'keras.layers'
Error

Line: 25 Column: 1

              from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.saving.saved_model import json_utils


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

            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 26 Column: 1

              from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.saving.saved_model import json_utils


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


            

Reported by Pylint.

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

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

import json
from keras import combinations
from keras import keras_parameterized
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training

            

Reported by Pylint.

Missing class docstring
Error

Line: 30 Column: 1

              

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

  def test_serialize_dense(self):
    dense = core.Dense(3)
    dense(tf.constant([[4.]]))
    round_trip = json.loads(json.dumps(

            

Reported by Pylint.

keras/distribute/distributed_file_utils.py
35 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 47 Column: 1

              Experimental. API is subject to change.
"""

import tensorflow.compat.v2 as tf

import os


def _get_base_dirpath(strategy):

            

Reported by Pylint.

TODO(anjalisridhar): Consider removing the check for multi worker mode since
Error

Line: 112 Column: 3

                  # If strategy is still not available, this is not in distributed training.
    # Fallback to no-op.
    return
  # TODO(anjalisridhar): Consider removing the check for multi worker mode since
  # it is redundant when used with the should_checkpoint property.
  if (strategy.extended._in_multi_worker_mode() and  # pylint: disable=protected-access
      not strategy.extended.should_checkpoint):
    # If this worker is not chief and hence should not save file, remove
    # the temporary directory.

            

Reported by Pylint.

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

Line: 49 Column: 1

              
import tensorflow.compat.v2 as tf

import os


def _get_base_dirpath(strategy):
  task_id = strategy.extended._task_id  # pylint: disable=protected-access
  return 'workertemp_' + str(task_id)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 53 Column: 1

              

def _get_base_dirpath(strategy):
  task_id = strategy.extended._task_id  # pylint: disable=protected-access
  return 'workertemp_' + str(task_id)


def _is_temp_dir(dirpath, strategy):
  return dirpath.endswith(_get_base_dirpath(strategy))

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 54 Column: 1

              
def _get_base_dirpath(strategy):
  task_id = strategy.extended._task_id  # pylint: disable=protected-access
  return 'workertemp_' + str(task_id)


def _is_temp_dir(dirpath, strategy):
  return dirpath.endswith(_get_base_dirpath(strategy))


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 58 Column: 1

              

def _is_temp_dir(dirpath, strategy):
  return dirpath.endswith(_get_base_dirpath(strategy))


def _get_temp_dir(dirpath, strategy):
  if _is_temp_dir(dirpath, strategy):
    temp_dir = dirpath

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 62 Column: 1

              

def _get_temp_dir(dirpath, strategy):
  if _is_temp_dir(dirpath, strategy):
    temp_dir = dirpath
  else:
    temp_dir = os.path.join(dirpath, _get_base_dirpath(strategy))
  tf.io.gfile.makedirs(temp_dir)
  return temp_dir

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 63 Column: 1

              
def _get_temp_dir(dirpath, strategy):
  if _is_temp_dir(dirpath, strategy):
    temp_dir = dirpath
  else:
    temp_dir = os.path.join(dirpath, _get_base_dirpath(strategy))
  tf.io.gfile.makedirs(temp_dir)
  return temp_dir


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 64 Column: 1

              def _get_temp_dir(dirpath, strategy):
  if _is_temp_dir(dirpath, strategy):
    temp_dir = dirpath
  else:
    temp_dir = os.path.join(dirpath, _get_base_dirpath(strategy))
  tf.io.gfile.makedirs(temp_dir)
  return temp_dir



            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 65 Column: 1

                if _is_temp_dir(dirpath, strategy):
    temp_dir = dirpath
  else:
    temp_dir = os.path.join(dirpath, _get_base_dirpath(strategy))
  tf.io.gfile.makedirs(temp_dir)
  return temp_dir


def write_dirpath(dirpath, strategy):

            

Reported by Pylint.

keras/distribute/collective_all_reduce_strategy_test.py
34 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for CollectiveAllReduceStrategy."""

import tensorflow.compat.v2 as tf

from absl.testing import parameterized
from keras import layers
from keras.engine import training
from keras.optimizer_v2 import gradient_descent as gradient_descent_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
from keras import layers
from keras.engine import training
from keras.optimizer_v2 import gradient_descent as gradient_descent_keras



            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 32 Column: 1

                          tf.__internal__.distribute.combinations.multi_worker_mirrored_2x1_gpu,
        ],
        mode=['eager']))
class MultiWorkerMirroredStrategyTest(tf.test.TestCase, parameterized.TestCase):

  def testFitWithoutStepsPerEpochPartialBatch(self, strategy):

    def _model_fn():
      x = layers.Input(shape=(1,), name='input')

            

Reported by Pylint.

Missing class docstring
Error

Line: 32 Column: 1

                          tf.__internal__.distribute.combinations.multi_worker_mirrored_2x1_gpu,
        ],
        mode=['eager']))
class MultiWorkerMirroredStrategyTest(tf.test.TestCase, parameterized.TestCase):

  def testFitWithoutStepsPerEpochPartialBatch(self, strategy):

    def _model_fn():
      x = layers.Input(shape=(1,), name='input')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 3

                      mode=['eager']))
class MultiWorkerMirroredStrategyTest(tf.test.TestCase, parameterized.TestCase):

  def testFitWithoutStepsPerEpochPartialBatch(self, strategy):

    def _model_fn():
      x = layers.Input(shape=(1,), name='input')
      y = layers.Dense(1, name='dense')(x)
      model = training.Model(x, y)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 34 Column: 1

                      mode=['eager']))
class MultiWorkerMirroredStrategyTest(tf.test.TestCase, parameterized.TestCase):

  def testFitWithoutStepsPerEpochPartialBatch(self, strategy):

    def _model_fn():
      x = layers.Input(shape=(1,), name='input')
      y = layers.Dense(1, name='dense')(x)
      model = training.Model(x, y)

            

Reported by Pylint.

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

Line: 34 Column: 3

                      mode=['eager']))
class MultiWorkerMirroredStrategyTest(tf.test.TestCase, parameterized.TestCase):

  def testFitWithoutStepsPerEpochPartialBatch(self, strategy):

    def _model_fn():
      x = layers.Input(shape=(1,), name='input')
      y = layers.Dense(1, name='dense')(x)
      model = training.Model(x, y)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 36 Column: 1

              
  def testFitWithoutStepsPerEpochPartialBatch(self, strategy):

    def _model_fn():
      x = layers.Input(shape=(1,), name='input')
      y = layers.Dense(1, name='dense')(x)
      model = training.Model(x, y)
      return model


            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 37 Column: 1

                def testFitWithoutStepsPerEpochPartialBatch(self, strategy):

    def _model_fn():
      x = layers.Input(shape=(1,), name='input')
      y = layers.Dense(1, name='dense')(x)
      model = training.Model(x, y)
      return model

    def _get_dataset():

            

Reported by Pylint.

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

Line: 37 Column: 7

                def testFitWithoutStepsPerEpochPartialBatch(self, strategy):

    def _model_fn():
      x = layers.Input(shape=(1,), name='input')
      y = layers.Dense(1, name='dense')(x)
      model = training.Model(x, y)
      return model

    def _get_dataset():

            

Reported by Pylint.

keras/applications/applications_load_weight_test.py
34 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 import flags
from absl.testing import parameterized
import numpy as np


            

Reported by Pylint.

Unable to import 'absl'
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

from absl import flags
from absl.testing import parameterized
import numpy as np

from keras.applications import densenet
from keras.applications import efficientnet

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf

from absl import flags
from absl.testing import parameterized
import numpy as np

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

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 83 Column: 1

                # the default is to accept variable-size inputs
  # even when loading ImageNet weights (since it is possible).
  # In this case, default to 299x299.
  if target_size[0] is None:
    target_size = (299, 299)
  test_image = data_utils.get_file('elephant.jpg', TEST_IMAGE_PATH)
  img = image.load_img(test_image, target_size=tuple(target_size))
  x = image.img_to_array(img)
  return np.expand_dims(x, axis=0)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 84 Column: 1

                # even when loading ImageNet weights (since it is possible).
  # In this case, default to 299x299.
  if target_size[0] is None:
    target_size = (299, 299)
  test_image = data_utils.get_file('elephant.jpg', TEST_IMAGE_PATH)
  img = image.load_img(test_image, target_size=tuple(target_size))
  x = image.img_to_array(img)
  return np.expand_dims(x, axis=0)


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 85 Column: 1

                # In this case, default to 299x299.
  if target_size[0] is None:
    target_size = (299, 299)
  test_image = data_utils.get_file('elephant.jpg', TEST_IMAGE_PATH)
  img = image.load_img(test_image, target_size=tuple(target_size))
  x = image.img_to_array(img)
  return np.expand_dims(x, axis=0)



            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 86 Column: 1

                if target_size[0] is None:
    target_size = (299, 299)
  test_image = data_utils.get_file('elephant.jpg', TEST_IMAGE_PATH)
  img = image.load_img(test_image, target_size=tuple(target_size))
  x = image.img_to_array(img)
  return np.expand_dims(x, axis=0)


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

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 87 Column: 1

                  target_size = (299, 299)
  test_image = data_utils.get_file('elephant.jpg', TEST_IMAGE_PATH)
  img = image.load_img(test_image, target_size=tuple(target_size))
  x = image.img_to_array(img)
  return np.expand_dims(x, axis=0)


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


            

Reported by Pylint.

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

Line: 87 Column: 3

                  target_size = (299, 299)
  test_image = data_utils.get_file('elephant.jpg', TEST_IMAGE_PATH)
  img = image.load_img(test_image, target_size=tuple(target_size))
  x = image.img_to_array(img)
  return np.expand_dims(x, axis=0)


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


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 88 Column: 1

                test_image = data_utils.get_file('elephant.jpg', TEST_IMAGE_PATH)
  img = image.load_img(test_image, target_size=tuple(target_size))
  x = image.img_to_array(img)
  return np.expand_dims(x, axis=0)


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

  def assertShapeEqual(self, shape1, shape2):

            

Reported by Pylint.