The following issues were found

keras/benchmarks/optimizer_benchmarks_test.py
29 issues
Unable to import 'tensorflow'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Benchmark tests for Keras optimizers."""

import tensorflow as tf

from keras.benchmarks import benchmark_util
from keras.optimizer_v2 import adam
from tensorflow.python.platform.benchmark import ParameterizedBenchmark


            

Reported by Pylint.

Unable to import 'tensorflow.python.platform.benchmark'
Error

Line: 21 Column: 1

              
from keras.benchmarks import benchmark_util
from keras.optimizer_v2 import adam
from tensorflow.python.platform.benchmark import ParameterizedBenchmark


def bidirect_imdb_lstm_config():
  """Bidirectional LSTM model and IMDB data."""


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 25 Column: 1

              

def bidirect_imdb_lstm_config():
  """Bidirectional LSTM model and IMDB data."""

  def model_fn():
    inputs = tf.keras.Input(shape=(None,), dtype="int32")
    x = tf.keras.layers.Embedding(20000, 128)(inputs)
    x = tf.keras.layers.Bidirectional(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 27 Column: 1

              def bidirect_imdb_lstm_config():
  """Bidirectional LSTM model and IMDB data."""

  def model_fn():
    inputs = tf.keras.Input(shape=(None,), dtype="int32")
    x = tf.keras.layers.Embedding(20000, 128)(inputs)
    x = tf.keras.layers.Bidirectional(
        tf.keras.layers.LSTM(64, return_sequences=True))(
            x)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 28 Column: 1

                """Bidirectional LSTM model and IMDB data."""

  def model_fn():
    inputs = tf.keras.Input(shape=(None,), dtype="int32")
    x = tf.keras.layers.Embedding(20000, 128)(inputs)
    x = tf.keras.layers.Bidirectional(
        tf.keras.layers.LSTM(64, return_sequences=True))(
            x)
    x = tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(64))(x)

            

Reported by Pylint.

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

Line: 29 Column: 5

              
  def model_fn():
    inputs = tf.keras.Input(shape=(None,), dtype="int32")
    x = tf.keras.layers.Embedding(20000, 128)(inputs)
    x = tf.keras.layers.Bidirectional(
        tf.keras.layers.LSTM(64, return_sequences=True))(
            x)
    x = tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(64))(x)
    outputs = tf.keras.layers.Dense(1, activation="sigmoid")(x)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 29 Column: 1

              
  def model_fn():
    inputs = tf.keras.Input(shape=(None,), dtype="int32")
    x = tf.keras.layers.Embedding(20000, 128)(inputs)
    x = tf.keras.layers.Bidirectional(
        tf.keras.layers.LSTM(64, return_sequences=True))(
            x)
    x = tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(64))(x)
    outputs = tf.keras.layers.Dense(1, activation="sigmoid")(x)

            

Reported by Pylint.

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

Line: 30 Column: 5

                def model_fn():
    inputs = tf.keras.Input(shape=(None,), dtype="int32")
    x = tf.keras.layers.Embedding(20000, 128)(inputs)
    x = tf.keras.layers.Bidirectional(
        tf.keras.layers.LSTM(64, return_sequences=True))(
            x)
    x = tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(64))(x)
    outputs = tf.keras.layers.Dense(1, activation="sigmoid")(x)
    model = tf.keras.Model(inputs, outputs)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 30 Column: 1

                def model_fn():
    inputs = tf.keras.Input(shape=(None,), dtype="int32")
    x = tf.keras.layers.Embedding(20000, 128)(inputs)
    x = tf.keras.layers.Bidirectional(
        tf.keras.layers.LSTM(64, return_sequences=True))(
            x)
    x = tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(64))(x)
    outputs = tf.keras.layers.Dense(1, activation="sigmoid")(x)
    model = tf.keras.Model(inputs, outputs)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 33 Column: 1

                  x = tf.keras.layers.Bidirectional(
        tf.keras.layers.LSTM(64, return_sequences=True))(
            x)
    x = tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(64))(x)
    outputs = tf.keras.layers.Dense(1, activation="sigmoid")(x)
    model = tf.keras.Model(inputs, outputs)
    return model

  (x_train, y_train), _ = tf.keras.datasets.imdb.load_data(num_words=20000)

            

Reported by Pylint.

keras/layers/preprocessing/category_crossing_distribution_test.py
29 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Distribution tests for keras.layers.preprocessing.category_crossing."""

import tensorflow.compat.v2 as tf

import numpy as np

import keras
from keras import keras_parameterized

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

              from keras.layers.preprocessing import preprocessing_test_utils


def batch_wrapper(dataset, batch_size, distribution, repeat=None):
  if repeat:
    dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(distribution,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 29 Column: 1

              

def batch_wrapper(dataset, batch_size, distribution, repeat=None):
  if repeat:
    dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(distribution,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 30 Column: 1

              
def batch_wrapper(dataset, batch_size, distribution, repeat=None):
  if repeat:
    dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(distribution,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 33 Column: 3

                  dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(distribution,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 33 Column: 1

                  dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(distribution,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


            

Reported by Pylint.

Line too long (108/100)
Error

Line: 34 Column: 1

                # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(distribution,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)



            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 35 Column: 1

                # the input will have fully defined shapes.
  if isinstance(distribution,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


@tf.__internal__.distribute.combinations.generate(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 36 Column: 1

                if isinstance(distribution,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


@tf.__internal__.distribute.combinations.generate(
    tf.__internal__.test.combinations.combine(

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 37 Column: 1

                              (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


@tf.__internal__.distribute.combinations.generate(
    tf.__internal__.test.combinations.combine(
        # Investigate why crossing is not supported with TPU.

            

Reported by Pylint.

keras/applications/resnet_v2.py
29 issues
Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 25 Column: 1

              
from keras.applications import imagenet_utils
from keras.applications import resnet
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.applications.resnet_v2.ResNet50V2',
              'keras.applications.ResNet50V2')
def ResNet50V2(

            

Reported by Pylint.

Too many arguments (7/5)
Error

Line: 30 Column: 1

              
@keras_export('keras.applications.resnet_v2.ResNet50V2',
              'keras.applications.ResNet50V2')
def ResNet50V2(
    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: 38 Column: 1

                  pooling=None,
    classes=1000,
    classifier_activation='softmax'):
  """Instantiates the ResNet50V2 architecture."""
  def stack_fn(x):
    x = resnet.stack2(x, 64, 3, name='conv2')
    x = resnet.stack2(x, 128, 4, name='conv3')
    x = resnet.stack2(x, 256, 6, name='conv4')
    return resnet.stack2(x, 512, 3, stride1=1, name='conv5')

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 39 Column: 1

                  classes=1000,
    classifier_activation='softmax'):
  """Instantiates the ResNet50V2 architecture."""
  def stack_fn(x):
    x = resnet.stack2(x, 64, 3, name='conv2')
    x = resnet.stack2(x, 128, 4, name='conv3')
    x = resnet.stack2(x, 256, 6, name='conv4')
    return resnet.stack2(x, 512, 3, stride1=1, name='conv5')


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 40 Column: 1

                  classifier_activation='softmax'):
  """Instantiates the ResNet50V2 architecture."""
  def stack_fn(x):
    x = resnet.stack2(x, 64, 3, name='conv2')
    x = resnet.stack2(x, 128, 4, name='conv3')
    x = resnet.stack2(x, 256, 6, name='conv4')
    return resnet.stack2(x, 512, 3, stride1=1, name='conv5')

  return resnet.ResNet(

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 41 Column: 1

                """Instantiates the ResNet50V2 architecture."""
  def stack_fn(x):
    x = resnet.stack2(x, 64, 3, name='conv2')
    x = resnet.stack2(x, 128, 4, name='conv3')
    x = resnet.stack2(x, 256, 6, name='conv4')
    return resnet.stack2(x, 512, 3, stride1=1, name='conv5')

  return resnet.ResNet(
      stack_fn,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 42 Column: 1

                def stack_fn(x):
    x = resnet.stack2(x, 64, 3, name='conv2')
    x = resnet.stack2(x, 128, 4, name='conv3')
    x = resnet.stack2(x, 256, 6, name='conv4')
    return resnet.stack2(x, 512, 3, stride1=1, name='conv5')

  return resnet.ResNet(
      stack_fn,
      True,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 43 Column: 1

                  x = resnet.stack2(x, 64, 3, name='conv2')
    x = resnet.stack2(x, 128, 4, name='conv3')
    x = resnet.stack2(x, 256, 6, name='conv4')
    return resnet.stack2(x, 512, 3, stride1=1, name='conv5')

  return resnet.ResNet(
      stack_fn,
      True,
      True,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 45 Column: 1

                  x = resnet.stack2(x, 256, 6, name='conv4')
    return resnet.stack2(x, 512, 3, stride1=1, name='conv5')

  return resnet.ResNet(
      stack_fn,
      True,
      True,
      'resnet50v2',
      include_top,

            

Reported by Pylint.

Too many arguments (7/5)
Error

Line: 61 Column: 1

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

            

Reported by Pylint.

keras/benchmarks/model_memory_profile.py
28 issues
Unable to import 'tensorflow'
Error

Line: 23 Column: 1

              3. Add the model function to the dict `models`.
"""

import tensorflow as tf

from absl import app
from absl import flags

from absl import logging

            

Reported by Pylint.

Unable to import 'absl'
Error

Line: 25 Column: 1

              
import tensorflow as tf

from absl import app
from absl import flags

from absl import logging
import numpy as np


            

Reported by Pylint.

Unable to import 'absl'
Error

Line: 26 Column: 1

              import tensorflow as tf

from absl import app
from absl import flags

from absl import logging
import numpy as np

try:

            

Reported by Pylint.

Unable to import 'absl'
Error

Line: 28 Column: 1

              from absl import app
from absl import flags

from absl import logging
import numpy as np

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

            

Reported by Pylint.

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

Line: 32 Column: 1

              import numpy as np

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


FLAGS = flags.FLAGS

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              import numpy as np

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


FLAGS = flags.FLAGS

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 34 Column: 1

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


FLAGS = flags.FLAGS
flags.DEFINE_string('model', None,
                    'The model to run memory profiler.')

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 44 Column: 1

              
@memory_profiler.profile
def _imdb_lstm_model():
  """LSTM model."""
  x_train = np.random.randint(0, 1999, size=(2500, 100))
  y_train = np.random.random((2500, 1))

  # IMDB LSTM model.
  model = tf.keras.Sequential()

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 45 Column: 1

              @memory_profiler.profile
def _imdb_lstm_model():
  """LSTM model."""
  x_train = np.random.randint(0, 1999, size=(2500, 100))
  y_train = np.random.random((2500, 1))

  # IMDB LSTM model.
  model = tf.keras.Sequential()
  model.add(tf.keras.layers.Embedding(20000, 128))

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 46 Column: 1

              def _imdb_lstm_model():
  """LSTM model."""
  x_train = np.random.randint(0, 1999, size=(2500, 100))
  y_train = np.random.random((2500, 1))

  # IMDB LSTM model.
  model = tf.keras.Sequential()
  model.add(tf.keras.layers.Embedding(20000, 128))
  model.add(tf.keras.layers.LSTM(128, dropout=0.2, recurrent_dropout=0.2))

            

Reported by Pylint.

keras/layers/preprocessing/category_encoding_distribution_test.py
28 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Distribution tests for keras.layers.preprocessing.category_encoding."""

import tensorflow.compat.v2 as tf

import numpy as np

import keras
from keras import keras_parameterized

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

              from keras.layers.preprocessing import preprocessing_test_utils


def batch_wrapper(dataset, batch_size, strategy, repeat=None):
  if repeat:
    dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(strategy,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 29 Column: 1

              

def batch_wrapper(dataset, batch_size, strategy, repeat=None):
  if repeat:
    dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(strategy,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 30 Column: 1

              
def batch_wrapper(dataset, batch_size, strategy, repeat=None):
  if repeat:
    dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(strategy,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 33 Column: 1

                  dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(strategy,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 33 Column: 3

                  dataset = dataset.repeat(repeat)
  # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(strategy,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


            

Reported by Pylint.

Line too long (108/100)
Error

Line: 34 Column: 1

                # TPUs currently require fully defined input shapes, drop_remainder ensures
  # the input will have fully defined shapes.
  if isinstance(strategy,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)



            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 35 Column: 1

                # the input will have fully defined shapes.
  if isinstance(strategy,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


@tf.__internal__.distribute.combinations.generate(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 36 Column: 1

                if isinstance(strategy,
                (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


@tf.__internal__.distribute.combinations.generate(
    tf.__internal__.test.combinations.combine(

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 37 Column: 1

                              (tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)):
    return dataset.batch(batch_size, drop_remainder=True)
  else:
    return dataset.batch(batch_size)


@tf.__internal__.distribute.combinations.generate(
    tf.__internal__.test.combinations.combine(
        # (b/156783625): Outside compilation failed for eager mode only.

            

Reported by Pylint.

keras/saving/saved_model/determinism_test.py
28 issues
Unable to import 'absl'
Error

Line: 5 Column: 1

              
import subprocess

from absl import flags
import tensorflow.compat.v2 as tf

# pylint: disable=g-direct-tensorflow-import
from tensorflow.core.protobuf import saved_model_pb2
# pylint: enable=g-direct-tensorflow-import

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 6 Column: 1

              import subprocess

from absl import flags
import tensorflow.compat.v2 as tf

# pylint: disable=g-direct-tensorflow-import
from tensorflow.core.protobuf import saved_model_pb2
# pylint: enable=g-direct-tensorflow-import


            

Reported by Pylint.

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

Line: 8 Column: 1

              from absl import flags
import tensorflow.compat.v2 as tf

# pylint: disable=g-direct-tensorflow-import
from tensorflow.core.protobuf import saved_model_pb2
# pylint: enable=g-direct-tensorflow-import

FLAGS = flags.FLAGS


            

Reported by Pylint.

Unable to import 'tensorflow.core.protobuf'
Error

Line: 9 Column: 1

              import tensorflow.compat.v2 as tf

# pylint: disable=g-direct-tensorflow-import
from tensorflow.core.protobuf import saved_model_pb2
# pylint: enable=g-direct-tensorflow-import

FLAGS = flags.FLAGS



            

Reported by Pylint.

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

Line: 10 Column: 1

              
# pylint: disable=g-direct-tensorflow-import
from tensorflow.core.protobuf import saved_model_pb2
# pylint: enable=g-direct-tensorflow-import

FLAGS = flags.FLAGS


class DeterminismTest(tf.test.TestCase):

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 3
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              """Saves the same model twice and ensures that they are serialized the same."""

import subprocess

from absl import flags
import tensorflow.compat.v2 as tf

# pylint: disable=g-direct-tensorflow-import
from tensorflow.core.protobuf import saved_model_pb2

            

Reported by Bandit.

Too few public methods (1/2)
Error

Line: 15 Column: 1

              FLAGS = flags.FLAGS


class DeterminismTest(tf.test.TestCase):

  def test_saving_is_deterministic(self):
    create_saved_model = f'{FLAGS.test_srcdir}/create_test_saved_model.par'
    saved_model_a_path = f'{FLAGS.test_tmpdir}/a'
    saved_model_b_path = f'{FLAGS.test_tmpdir}/b'

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              FLAGS = flags.FLAGS


class DeterminismTest(tf.test.TestCase):

  def test_saving_is_deterministic(self):
    create_saved_model = f'{FLAGS.test_srcdir}/create_test_saved_model.par'
    saved_model_a_path = f'{FLAGS.test_tmpdir}/a'
    saved_model_b_path = f'{FLAGS.test_tmpdir}/b'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 3

              
class DeterminismTest(tf.test.TestCase):

  def test_saving_is_deterministic(self):
    create_saved_model = f'{FLAGS.test_srcdir}/create_test_saved_model.par'
    saved_model_a_path = f'{FLAGS.test_tmpdir}/a'
    saved_model_b_path = f'{FLAGS.test_tmpdir}/b'

    save_a = subprocess.Popen(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 17 Column: 1

              
class DeterminismTest(tf.test.TestCase):

  def test_saving_is_deterministic(self):
    create_saved_model = f'{FLAGS.test_srcdir}/create_test_saved_model.par'
    saved_model_a_path = f'{FLAGS.test_tmpdir}/a'
    saved_model_b_path = f'{FLAGS.test_tmpdir}/b'

    save_a = subprocess.Popen(

            

Reported by Pylint.

keras/optimizers.py
28 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 21 Column: 1

              For more examples see the base class `tf.keras.optimizers.Optimizer`.
"""

import tensorflow.compat.v2 as tf

from keras import backend
from keras.optimizer_v1 import Optimizer
from keras.optimizer_v1 import TFOptimizer
from keras.optimizer_v2 import adadelta as adadelta_v2

            

Reported by Pylint.

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

Line: 37 Column: 1

              from keras.optimizer_v2 import rmsprop as rmsprop_v2
from keras.utils.generic_utils import deserialize_keras_object
from keras.utils.generic_utils import serialize_keras_object
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.optimizers.serialize')
def serialize(optimizer):
  """Serialize the optimizer configuration to JSON compatible python dict.

            

Reported by Pylint.

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

Line: 75 Column: 1

                """
  # loss_scale_optimizer has a direct dependency of optimizer, import here
  # rather than top to avoid the cyclic dependency.
  from keras.mixed_precision import loss_scale_optimizer  # pylint: disable=g-import-not-at-top
  all_classes = {
      'adadelta': adadelta_v2.Adadelta,
      'adagrad': adagrad_v2.Adagrad,
      'adam': adam_v2.Adam,
      'adamax': adamax_v2.Adamax,

            

Reported by Pylint.

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

Line: 37 Column: 1

              from keras.optimizer_v2 import rmsprop as rmsprop_v2
from keras.utils.generic_utils import deserialize_keras_object
from keras.utils.generic_utils import serialize_keras_object
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.optimizers.serialize')
def serialize(optimizer):
  """Serialize the optimizer configuration to JSON compatible python dict.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 42 Column: 1

              
@keras_export('keras.optimizers.serialize')
def serialize(optimizer):
  """Serialize the optimizer configuration to JSON compatible python dict.

  The configuration can be used for persistence and reconstruct the `Optimizer`
  instance again.

  >>> tf.keras.optimizers.serialize(tf.keras.optimizers.SGD())

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 58 Column: 1

                Returns:
    Python dict which contains the configuration of the input optimizer.
  """
  return serialize_keras_object(optimizer)


@keras_export('keras.optimizers.deserialize')
def deserialize(config, custom_objects=None):
  """Inverse of the `serialize` function.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 63 Column: 1

              
@keras_export('keras.optimizers.deserialize')
def deserialize(config, custom_objects=None):
  """Inverse of the `serialize` function.

  Args:
      config: Optimizer configuration dictionary.
      custom_objects: Optional dictionary mapping names (strings) to custom
        objects (classes and functions) to be considered during deserialization.

            

Reported by Pylint.

Import outside toplevel (keras.mixed_precision.loss_scale_optimizer)
Error

Line: 75 Column: 3

                """
  # loss_scale_optimizer has a direct dependency of optimizer, import here
  # rather than top to avoid the cyclic dependency.
  from keras.mixed_precision import loss_scale_optimizer  # pylint: disable=g-import-not-at-top
  all_classes = {
      'adadelta': adadelta_v2.Adadelta,
      'adagrad': adagrad_v2.Adagrad,
      'adam': adam_v2.Adam,
      'adamax': adamax_v2.Adamax,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 75 Column: 1

                """
  # loss_scale_optimizer has a direct dependency of optimizer, import here
  # rather than top to avoid the cyclic dependency.
  from keras.mixed_precision import loss_scale_optimizer  # pylint: disable=g-import-not-at-top
  all_classes = {
      'adadelta': adadelta_v2.Adadelta,
      'adagrad': adagrad_v2.Adagrad,
      'adam': adam_v2.Adam,
      'adamax': adamax_v2.Adamax,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 76 Column: 1

                # loss_scale_optimizer has a direct dependency of optimizer, import here
  # rather than top to avoid the cyclic dependency.
  from keras.mixed_precision import loss_scale_optimizer  # pylint: disable=g-import-not-at-top
  all_classes = {
      'adadelta': adadelta_v2.Adadelta,
      'adagrad': adagrad_v2.Adagrad,
      'adam': adam_v2.Adam,
      'adamax': adamax_v2.Adamax,
      'nadam': nadam_v2.Nadam,

            

Reported by Pylint.

keras/layers/core/permute.py
27 issues
Bad option value 'g-classes-have-attributes'
Error

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================
"""Contains the Permute layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import

import copy
from keras.engine.base_layer import Layer
from keras.engine.input_spec import InputSpec
import tensorflow.compat.v2 as tf

            

Reported by Pylint.

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

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================
"""Contains the Permute layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import

import copy
from keras.engine.base_layer import Layer
from keras.engine.input_spec import InputSpec
import tensorflow.compat.v2 as tf

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 21 Column: 1

              import copy
from keras.engine.base_layer import Layer
from keras.engine.input_spec import InputSpec
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.layers.Permute')
class Permute(Layer):

            

Reported by Pylint.

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

Line: 22 Column: 1

              from keras.engine.base_layer import Layer
from keras.engine.input_spec import InputSpec
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.layers.Permute')
class Permute(Layer):
  """Permutes the dimensions of the input according to a given pattern.

            

Reported by Pylint.

Parameters differ from overridden 'call' method
Error

Line: 74 Column: 3

                    output_shape[i + 1] = target_dim
    return tf.TensorShape(output_shape)

  def call(self, inputs):
    return tf.transpose(inputs, perm=(0,) + self.dims)

  def get_config(self):
    config = {'dims': self.dims}
    base_config = super(Permute, self).get_config()

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 27 Column: 1

              
@keras_export('keras.layers.Permute')
class Permute(Layer):
  """Permutes the dimensions of the input according to a given pattern.

  Useful e.g. connecting RNNs and convnets.

  Example:


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 56 Column: 1

                  to the specified pattern.
  """

  def __init__(self, dims, **kwargs):
    super(Permute, self).__init__(**kwargs)
    self.dims = tuple(dims)
    if sorted(dims) != list(range(1, len(dims) + 1)):
      raise ValueError(
          'Invalid permutation argument `dims` for Permute Layer. '

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 57 Column: 1

                """

  def __init__(self, dims, **kwargs):
    super(Permute, self).__init__(**kwargs)
    self.dims = tuple(dims)
    if sorted(dims) != list(range(1, len(dims) + 1)):
      raise ValueError(
          'Invalid permutation argument `dims` for Permute Layer. '
          'The set of indices in `dims` must be consecutive and start from 1. '

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 57 Column: 5

                """

  def __init__(self, dims, **kwargs):
    super(Permute, self).__init__(**kwargs)
    self.dims = tuple(dims)
    if sorted(dims) != list(range(1, len(dims) + 1)):
      raise ValueError(
          'Invalid permutation argument `dims` for Permute Layer. '
          'The set of indices in `dims` must be consecutive and start from 1. '

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 58 Column: 1

              
  def __init__(self, dims, **kwargs):
    super(Permute, self).__init__(**kwargs)
    self.dims = tuple(dims)
    if sorted(dims) != list(range(1, len(dims) + 1)):
      raise ValueError(
          'Invalid permutation argument `dims` for Permute Layer. '
          'The set of indices in `dims` must be consecutive and start from 1. '
          f'Received dims={dims}')

            

Reported by Pylint.

keras/backend_config_test.py
27 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for backend_config."""

import tensorflow.compat.v2 as tf

from keras import backend
from keras import backend_config
from keras import combinations


            

Reported by Pylint.

Missing class docstring
Error

Line: 25 Column: 1

              

@combinations.generate(combinations.combine(mode=['graph', 'eager']))
class BackendConfigTest(tf.test.TestCase):

  def test_backend(self):
    self.assertEqual(backend.backend(), 'tensorflow')

  def test_epsilon(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 3

              @combinations.generate(combinations.combine(mode=['graph', 'eager']))
class BackendConfigTest(tf.test.TestCase):

  def test_backend(self):
    self.assertEqual(backend.backend(), 'tensorflow')

  def test_epsilon(self):
    epsilon = 1e-2
    backend_config.set_epsilon(epsilon)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 27 Column: 1

              @combinations.generate(combinations.combine(mode=['graph', 'eager']))
class BackendConfigTest(tf.test.TestCase):

  def test_backend(self):
    self.assertEqual(backend.backend(), 'tensorflow')

  def test_epsilon(self):
    epsilon = 1e-2
    backend_config.set_epsilon(epsilon)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 28 Column: 1

              class BackendConfigTest(tf.test.TestCase):

  def test_backend(self):
    self.assertEqual(backend.backend(), 'tensorflow')

  def test_epsilon(self):
    epsilon = 1e-2
    backend_config.set_epsilon(epsilon)
    self.assertEqual(backend_config.epsilon(), epsilon)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

                def test_backend(self):
    self.assertEqual(backend.backend(), 'tensorflow')

  def test_epsilon(self):
    epsilon = 1e-2
    backend_config.set_epsilon(epsilon)
    self.assertEqual(backend_config.epsilon(), epsilon)
    backend_config.set_epsilon(1e-7)
    self.assertEqual(backend_config.epsilon(), 1e-7)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 3

                def test_backend(self):
    self.assertEqual(backend.backend(), 'tensorflow')

  def test_epsilon(self):
    epsilon = 1e-2
    backend_config.set_epsilon(epsilon)
    self.assertEqual(backend_config.epsilon(), epsilon)
    backend_config.set_epsilon(1e-7)
    self.assertEqual(backend_config.epsilon(), 1e-7)

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 31 Column: 1

                  self.assertEqual(backend.backend(), 'tensorflow')

  def test_epsilon(self):
    epsilon = 1e-2
    backend_config.set_epsilon(epsilon)
    self.assertEqual(backend_config.epsilon(), epsilon)
    backend_config.set_epsilon(1e-7)
    self.assertEqual(backend_config.epsilon(), 1e-7)


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 32 Column: 1

              
  def test_epsilon(self):
    epsilon = 1e-2
    backend_config.set_epsilon(epsilon)
    self.assertEqual(backend_config.epsilon(), epsilon)
    backend_config.set_epsilon(1e-7)
    self.assertEqual(backend_config.epsilon(), 1e-7)

  def test_floatx(self):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 33 Column: 1

                def test_epsilon(self):
    epsilon = 1e-2
    backend_config.set_epsilon(epsilon)
    self.assertEqual(backend_config.epsilon(), epsilon)
    backend_config.set_epsilon(1e-7)
    self.assertEqual(backend_config.epsilon(), 1e-7)

  def test_floatx(self):
    floatx = 'float64'

            

Reported by Pylint.

keras/layers/core/masking.py
26 issues
Bad option value 'g-classes-have-attributes'
Error

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================
"""Contains the Masking layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import

from keras import backend as K
from keras.engine.base_layer import Layer
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export

            

Reported by Pylint.

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

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================
"""Contains the Masking layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import

from keras import backend as K
from keras.engine.base_layer import Layer
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 20 Column: 1

              
from keras import backend as K
from keras.engine.base_layer import Layer
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.layers.Masking')
class Masking(Layer):

            

Reported by Pylint.

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

Line: 21 Column: 1

              from keras import backend as K
from keras.engine.base_layer import Layer
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export


@keras_export('keras.layers.Masking')
class Masking(Layer):
  """Masks a sequence by using a mask value to skip timesteps.

            

Reported by Pylint.

Parameters differ from overridden 'call' method
Error

Line: 74 Column: 3

                def compute_mask(self, inputs, mask=None):
    return K.any(tf.not_equal(inputs, self.mask_value), axis=-1)

  def call(self, inputs):
    boolean_mask = K.any(
        tf.not_equal(inputs, self.mask_value), axis=-1, keepdims=True)
    outputs = inputs * tf.cast(boolean_mask, inputs.dtype)
    # Compute the mask and outputs simultaneously.
    outputs._keras_mask = tf.squeeze(boolean_mask, axis=-1)  # pylint: disable=protected-access

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 26 Column: 1

              
@keras_export('keras.layers.Masking')
class Masking(Layer):
  """Masks a sequence by using a mask value to skip timesteps.

  For each timestep in the input tensor (dimension #1 in the tensor),
  if all values in the input tensor at that timestep
  are equal to `mask_value`, then the timestep will be masked (skipped)
  in all downstream layers (as long as they support masking).

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 65 Column: 1

                for more details.
  """

  def __init__(self, mask_value=0., **kwargs):
    super(Masking, self).__init__(**kwargs)
    self.supports_masking = True
    self.mask_value = mask_value
    self._compute_output_and_mask_jointly = True


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 66 Column: 1

                """

  def __init__(self, mask_value=0., **kwargs):
    super(Masking, self).__init__(**kwargs)
    self.supports_masking = True
    self.mask_value = mask_value
    self._compute_output_and_mask_jointly = True

  def compute_mask(self, inputs, mask=None):

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 66 Column: 5

                """

  def __init__(self, mask_value=0., **kwargs):
    super(Masking, self).__init__(**kwargs)
    self.supports_masking = True
    self.mask_value = mask_value
    self._compute_output_and_mask_jointly = True

  def compute_mask(self, inputs, mask=None):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 67 Column: 1

              
  def __init__(self, mask_value=0., **kwargs):
    super(Masking, self).__init__(**kwargs)
    self.supports_masking = True
    self.mask_value = mask_value
    self._compute_output_and_mask_jointly = True

  def compute_mask(self, inputs, mask=None):
    return K.any(tf.not_equal(inputs, self.mask_value), axis=-1)

            

Reported by Pylint.