The following issues were found

keras/saving/save_test.py
847 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for Keras model saving code."""

import tensorflow.compat.v2 as tf

import collections
import os
import pathlib
import shutil

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 26 Column: 1

              import tempfile
import warnings

from absl.testing import parameterized
import numpy as np

import keras
from keras import combinations
from keras import keras_parameterized

            

Reported by Pylint.

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

Line: 47 Column: 1

              

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


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

            

Reported by Pylint.

Module 'keras.initializers' has no 'Constant' member
Error

Line: 738 Column: 32

                      keras.layers.Dense(
            2,
            input_shape=(3,),
            kernel_initializer=keras.initializers.Constant(np.ones((3, 2)))))
    model.add(keras.layers.Dense(3))
    model.compile(loss='mse', optimizer='sgd', metrics=['acc'])
    keras.models.save_model(model, saved_model_dir, save_format=save_format)
    model = keras.models.load_model(saved_model_dir)


            

Reported by Pylint.

TODO(tibell): Figure out the right dtype and apply masking.
Error

Line: 184 Column: 3

                  }

    fc_layer, _ = ksfc.SequenceFeatures(cols)(input_layers)
    # TODO(tibell): Figure out the right dtype and apply masking.
    # sequence_length_mask = array_ops.sequence_mask(sequence_length)
    # x = keras.layers.GRU(32)(fc_layer, mask=sequence_length_mask)
    x = keras.layers.GRU(32)(fc_layer)
    output = keras.layers.Dense(10)(x)


            

Reported by Pylint.

Method 'get_config' is abstract in class 'Model' but is not overridden
Error

Line: 250 Column: 5

                @combinations.generate(combinations.combine(mode=['graph', 'eager']))
  def test_saving_optimizer_weights(self):

    class MyModel(keras.Model):

      def __init__(self):
        super(MyModel, self).__init__()
        self.layer = keras.layers.Dense(1)


            

Reported by Pylint.

Parameters differ from overridden 'call' method
Error

Line: 256 Column: 7

                      super(MyModel, self).__init__()
        self.layer = keras.layers.Dense(1)

      def call(self, x):
        return self.layer(x)

    path = os.path.join(self.get_temp_dir(), 'weights_path')
    x, y = np.ones((10, 10)), np.ones((10, 1))


            

Reported by Pylint.

TODO(b/153110928): Keras TF format doesn't restore optimizer weights
Error

Line: 342 Column: 3

              
    if loaded_model.optimizer:
      if testing_utils.get_save_format() == 'tf':
        # TODO(b/153110928): Keras TF format doesn't restore optimizer weights
        # currently.
        return
      self.assertAllClose(model.optimizer.weights,
                          loaded_model.optimizer.weights)


            

Reported by Pylint.

Access to a protected member _make_train_function of a client class
Error

Line: 536 Column: 9

                    model.add(keras.layers.Dense(3))
      model.compile(loss='mse', optimizer='sgd', metrics=['acc'])
      if not tf.compat.v1.executing_eagerly_outside_functions():
        model._make_train_function()
      keras.models.save_model(model, saved_model_dir, save_format=save_format)
      model = keras.models.load_model(saved_model_dir)

  def test_saving_lambda_numpy_array_arguments(self):
    saved_model_dir = self._save_model_dir()

            

Reported by Pylint.

Method 'get_config' is abstract in class 'Model' but is not overridden
Error

Line: 865 Column: 7

                def test_custom_functional_registered(self):

    def _get_cls_definition():
      class CustomModel(keras.Model):

        def c(self):
          return 'c'

      return CustomModel

            

Reported by Pylint.

keras/optimizer_v2/adam_test.py
844 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for Adam."""

import tensorflow.compat.v2 as tf

from absl.testing import parameterized
import numpy as np
from keras import combinations
from keras import optimizer_v1

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

from absl.testing import parameterized
import numpy as np
from keras import combinations
from keras import optimizer_v1
from keras.optimizer_v2 import adam
from keras.optimizer_v2 import learning_rate_schedule

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 21 Column: 1

              
from absl.testing import parameterized
import numpy as np
from keras import combinations
from keras import optimizer_v1
from keras.optimizer_v2 import adam
from keras.optimizer_v2 import learning_rate_schedule



            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 22 Column: 1

              from absl.testing import parameterized
import numpy as np
from keras import combinations
from keras import optimizer_v1
from keras.optimizer_v2 import adam
from keras.optimizer_v2 import learning_rate_schedule


def adam_update_numpy(param,

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 23 Column: 1

              import numpy as np
from keras import combinations
from keras import optimizer_v1
from keras.optimizer_v2 import adam
from keras.optimizer_v2 import learning_rate_schedule


def adam_update_numpy(param,
                      g_t,

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 24 Column: 1

              from keras import combinations
from keras import optimizer_v1
from keras.optimizer_v2 import adam
from keras.optimizer_v2 import learning_rate_schedule


def adam_update_numpy(param,
                      g_t,
                      t,

            

Reported by Pylint.

Access to a protected member _get_hyper of a client class
Error

Line: 93 Column: 22

              
def get_beta_accumulators(opt, dtype):
  local_step = tf.cast(opt.iterations + 1, dtype)
  beta_1_t = tf.cast(opt._get_hyper("beta_1"), dtype)
  beta_1_power = tf.pow(beta_1_t, local_step)
  beta_2_t = tf.cast(opt._get_hyper("beta_2"), dtype)
  beta_2_power = tf.pow(beta_2_t, local_step)
  return (beta_1_power, beta_2_power)


            

Reported by Pylint.

Access to a protected member _get_hyper of a client class
Error

Line: 95 Column: 22

                local_step = tf.cast(opt.iterations + 1, dtype)
  beta_1_t = tf.cast(opt._get_hyper("beta_1"), dtype)
  beta_1_power = tf.pow(beta_1_t, local_step)
  beta_2_t = tf.cast(opt._get_hyper("beta_2"), dtype)
  beta_2_power = tf.pow(beta_2_t, local_step)
  return (beta_1_power, beta_2_power)


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

            

Reported by Pylint.

TODO(tanzheny, omalleyt): Fix test in eager mode.
Error

Line: 103 Column: 3

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

  def testSparse(self):
    # TODO(tanzheny, omalleyt): Fix test in eager mode.
    for dtype in [tf.half, tf.float32, tf.float64]:
      with tf.Graph().as_default(), self.cached_session():
        # Initialize variables for numpy implementation.
        m0, v0, m1, v1 = 0.0, 0.0, 0.0, 0.0
        var0_np = np.array([1.0, 1.0, 2.0], dtype=dtype.as_numpy_dtype)

            

Reported by Pylint.

TODO(tanzheny, omalleyt): Fix test in eager mode.
Error

Line: 148 Column: 3

                        self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1))

  def testSparseDevicePlacement(self):
    # TODO(tanzheny, omalleyt): Fix test in eager mode.
    for index_dtype in [tf.int32, tf.int64]:
      with tf.Graph().as_default(), self.cached_session(
          force_gpu=tf.test.is_gpu_available()):
        # If a GPU is available, tests that all optimizer ops can be placed on
        # it (i.e. they have GPU kernels).

            

Reported by Pylint.

keras/engine/data_adapter_test.py
815 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""DataAdapter tests."""

import tensorflow.compat.v2 as tf

import math

from absl.testing import parameterized
import numpy as np

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 21 Column: 1

              
import math

from absl.testing import parameterized
import numpy as np

import keras
from keras import keras_parameterized
from keras import testing_utils

            

Reported by Pylint.

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

Line: 155 Column: 1

              
  def test_can_handle_pandas(self):
    try:
      import pandas as pd  # pylint: disable=g-import-not-at-top
    except ImportError:
      self.skipTest('Skipping test because pandas is not installed.')
    self.assertTrue(self.adapter_cls.can_handle(pd.DataFrame(self.numpy_input)))
    self.assertTrue(
        self.adapter_cls.can_handle(pd.DataFrame(self.numpy_input)[0]))

            

Reported by Pylint.

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

Line: 169 Column: 1

                @keras_parameterized.run_all_keras_modes(always_skip_v1=True)
  def test_training_pandas(self):
    try:
      import pandas as pd  # pylint: disable=g-import-not-at-top
    except ImportError:
      self.skipTest('Skipping test because pandas is not installed.')
    input_a = keras.Input(shape=(3,), name='input_a')
    input_b = keras.Input(shape=(3,), name='input_b')
    input_c = keras.Input(shape=(1,), name='input_b')

            

Reported by Pylint.

Method 'get_config' is abstract in class 'Model' but is not overridden
Error

Line: 730 Column: 5

              
  def test_model_without_forward_pass(self):

    class MyModel(keras.Model):

      def train_step(self, data):
        return {'loss': 0.}

      def test_step(self, data):

            

Reported by Pylint.

Method 'call' is abstract in class 'Model' but is not overridden
Error

Line: 730 Column: 5

              
  def test_model_without_forward_pass(self):

    class MyModel(keras.Model):

      def train_step(self, data):
        return {'loss': 0.}

      def test_step(self, data):

            

Reported by Pylint.

Access to a protected member _adapter of a client class
Error

Line: 811 Column: 22

                  data_handler = data_adapter.DataHandler(
        data, initial_epoch=0, epochs=2, steps_per_epoch=2)
    self.assertEqual(data_handler.inferred_steps, 2)
    self.assertFalse(data_handler._adapter.should_recreate_iterator())
    returned_data = []
    for _, iterator in data_handler.enumerate_epochs():
      epoch_data = []
      for _ in data_handler.steps():
        epoch_data.append(next(iterator).numpy())

            

Reported by Pylint.

Access to a protected member _adapter of a client class
Error

Line: 838 Column: 21

                  # create a new iterator each epoch.
    data_handler = data_adapter.DataHandler(
        data, initial_epoch=0, epochs=2, steps_per_epoch=4)
    self.assertTrue(data_handler._adapter.should_recreate_iterator())
    returned_data = []
    for _, iterator in data_handler.enumerate_epochs():
      epoch_data = []
      for _ in data_handler.steps():
        epoch_data.append(next(iterator).numpy())

            

Reported by Pylint.

Access to a protected member _adapter of a client class
Error

Line: 868 Column: 22

                  # User can choose to only partially consume `Dataset`.
    data_handler = data_adapter.DataHandler(
        filtered_ds, initial_epoch=0, epochs=2, steps_per_epoch=2)
    self.assertFalse(data_handler._adapter.should_recreate_iterator())
    returned_data = []
    for _, iterator in data_handler.enumerate_epochs():
      epoch_data = []
      for _ in data_handler.steps():
        epoch_data.append(next(iterator))

            

Reported by Pylint.

Access to a protected member _adapter of a client class
Error

Line: 888 Column: 21

                  data_handler = data_adapter.DataHandler(
        filtered_ds, initial_epoch=0, epochs=2)
    self.assertEqual(data_handler.inferred_steps, None)
    self.assertTrue(data_handler._adapter.should_recreate_iterator())
    returned_data = []
    for _, iterator in data_handler.enumerate_epochs():
      epoch_data = []
      with data_handler.catch_stop_iteration():
        for _ in data_handler.steps():

            

Reported by Pylint.

keras/engine/functional.py
766 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 18 Column: 1

              # pylint: disable=protected-access
"""A `Network` is way to compose layers: the topological form of a `Model`."""

import tensorflow.compat.v2 as tf

import collections
import copy
import itertools
import warnings

            

Reported by Pylint.

Unable to import 'tensorflow.python.platform'
Error

Line: 37 Column: 1

              from keras.utils import generic_utils
from keras.utils import tf_inspect
from keras.utils import tf_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.tools.docs import doc_controls


# pylint: disable=g-classes-have-attributes
class Functional(training_lib.Model):

            

Reported by Pylint.

Unable to import 'tensorflow.tools.docs'
Error

Line: 38 Column: 1

              from keras.utils import tf_inspect
from keras.utils import tf_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.tools.docs import doc_controls


# pylint: disable=g-classes-have-attributes
class Functional(training_lib.Model):
  """A `Functional` model is a `Model` defined as a directed graph of layers.

            

Reported by Pylint.

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

Line: 41 Column: 1

              from tensorflow.tools.docs import doc_controls


# pylint: disable=g-classes-have-attributes
class Functional(training_lib.Model):
  """A `Functional` model is a `Model` defined as a directed graph of layers.

  Three types of `Model` exist: subclassed `Model`, `Functional` model,
  and `Sequential` (a special case of `Functional`).

            

Reported by Pylint.

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

Line: 1254 Column: 1

                    layer = created_layers[layer_name]
    else:
      # Instantiate layer.
      from keras.layers import deserialize as deserialize_layer  # pylint: disable=g-import-not-at-top

      layer = deserialize_layer(layer_data, custom_objects=custom_objects)
      created_layers[layer_name] = layer

    node_count_by_layer[layer] = int(_should_skip_first_node(layer))

            

Reported by Pylint.

Signature differs from overridden 'compute_mask' method
Error

Line: 396 Column: 3

                def _should_compute_mask(self):
    return True

  def compute_mask(self, inputs, mask):
    # TODO(omalleyt): b/123540974 This function is not really safe to call
    # by itself because it will duplicate any updates and losses in graph
    # mode by `call`ing the Layers again.
    output_tensors = self._run_internal_graph(inputs, mask=mask)
    return tf.nest.map_structure(lambda t: getattr(t, '_keras_mask', None),

            

Reported by Pylint.

TODO(omalleyt): b/123540974 This function is not really safe to call
Error

Line: 397 Column: 3

                  return True

  def compute_mask(self, inputs, mask):
    # TODO(omalleyt): b/123540974 This function is not really safe to call
    # by itself because it will duplicate any updates and losses in graph
    # mode by `call`ing the Layers again.
    output_tensors = self._run_internal_graph(inputs, mask=mask)
    return tf.nest.map_structure(lambda t: getattr(t, '_keras_mask', None),
                              output_tensors)

            

Reported by Pylint.

Unused argument 'training'
Error

Line: 517 Column: 41

                  else:
      self._name = name

  def _run_internal_graph(self, inputs, training=None, mask=None):
    """Computes output tensors for new inputs.

    # Note:
        - Can be run on non-Keras tensors.


            

Reported by Pylint.

TODO(b/151582614)
Error

Line: 603 Column: 3

                      # Flatten in the order `Input`s were passed during Model construction.
        return [tensors[n] for n in ref_input_names]
      except KeyError:
        # TODO(b/151582614)
        return tf.nest.flatten(tensors)

    # Otherwise both self.inputs and tensors will already be in same order.
    return tf.nest.flatten(tensors)


            

Reported by Pylint.

Attribute '_tensor_usage_count' defined outside __init__
Error

Line: 840 Column: 5

                  for tensor in self.outputs:
      tensor_usage_count[str(id(tensor))] += 1

    self._tensor_usage_count = tensor_usage_count

  def _assert_weights_created(self):
    # Override the implementation in Model.
    # The Functional model should always have weight created already.
    return

            

Reported by Pylint.

keras/layers/lstm_v2_test.py
756 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for V2 LSTM layer."""

import tensorflow.compat.v2 as tf

import copy
import os
import shutil
import time

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 24 Column: 1

              import shutil
import time

from absl.testing import parameterized
import numpy as np
from tensorflow.core.protobuf import rewriter_config_pb2
import keras
from tensorflow.python.framework import test_util as tf_test_util
from keras import keras_parameterized

            

Reported by Pylint.

Unable to import 'tensorflow.core.protobuf'
Error

Line: 26 Column: 1

              
from absl.testing import parameterized
import numpy as np
from tensorflow.core.protobuf import rewriter_config_pb2
import keras
from tensorflow.python.framework import test_util as tf_test_util
from keras import keras_parameterized
from keras import testing_utils
from keras.layers import recurrent as rnn_v1

            

Reported by Pylint.

Unable to import 'tensorflow.python.framework'
Error

Line: 28 Column: 1

              import numpy as np
from tensorflow.core.protobuf import rewriter_config_pb2
import keras
from tensorflow.python.framework import test_util as tf_test_util
from keras import keras_parameterized
from keras import testing_utils
from keras.layers import recurrent as rnn_v1
from keras.layers import recurrent_v2 as rnn
from keras.utils import np_utils

            

Reported by Pylint.

Unable to import 'tensorflow.python.platform'
Error

Line: 34 Column: 1

              from keras.layers import recurrent as rnn_v1
from keras.layers import recurrent_v2 as rnn
from keras.utils import np_utils
from tensorflow.python.platform import tf_logging as logging


# Global config for grappler setting that is used for graph mode test.
_rewrites = rewriter_config_pb2.RewriterConfig()
_rewrites.implementation_selector = rewriter_config_pb2.RewriterConfig.ON

            

Reported by Pylint.

Access to a protected member _could_use_gpu_kernel of a client class
Error

Line: 64 Column: 22

                      recurrent_dropout=recurrent_dropout,
        unroll=unroll,
        use_bias=use_bias)
    self.assertFalse(layer._could_use_gpu_kernel)

  @testing_utils.run_v2_only
  def test_use_on_default_activation_with_gpu_kernel(self):
    layer = rnn.LSTM(1, activation=tf.tanh)
    self.assertTrue(layer._could_use_gpu_kernel)

            

Reported by Pylint.

Access to a protected member _could_use_gpu_kernel of a client class
Error

Line: 69 Column: 21

                @testing_utils.run_v2_only
  def test_use_on_default_activation_with_gpu_kernel(self):
    layer = rnn.LSTM(1, activation=tf.tanh)
    self.assertTrue(layer._could_use_gpu_kernel)

    layer = rnn.LSTM(1, recurrent_activation=tf.sigmoid)
    self.assertTrue(layer._could_use_gpu_kernel)

  def test_static_shape_inference_LSTM(self):

            

Reported by Pylint.

Access to a protected member _could_use_gpu_kernel of a client class
Error

Line: 72 Column: 21

                  self.assertTrue(layer._could_use_gpu_kernel)

    layer = rnn.LSTM(1, recurrent_activation=tf.sigmoid)
    self.assertTrue(layer._could_use_gpu_kernel)

  def test_static_shape_inference_LSTM(self):
    # Github issue: 15165
    timesteps = 3
    embedding_dim = 4

            

Reported by Pylint.

Access to a protected member _inbound_nodes of a client class
Error

Line: 138 Column: 22

                    output = layer(inputs, initial_state=initial_state)
    self.assertTrue(
        any(initial_state[0] is t
            for t in layer._inbound_nodes[0].input_tensors))

    model = keras.models.Model([inputs] + initial_state, output)
    model.compile(
        loss='categorical_crossentropy',
        optimizer=tf.compat.v1.train.GradientDescentOptimizer(0.01))

            

Reported by Pylint.

Access to a protected member _inbound_nodes of a client class
Error

Line: 295 Column: 22

                  output = layer(inputs)
    self.assertTrue(
        any(initial_state[0] is t
            for t in layer._inbound_nodes[0].input_tensors))

    model = keras.models.Model(inputs, output)
    model.compile(
        loss='categorical_crossentropy',
        optimizer=tf.compat.v1.train.GradientDescentOptimizer(0.01))

            

Reported by Pylint.

keras/mixed_precision/loss_scale_optimizer_test.py
753 issues
Unable to import 'absl.testing'
Error

Line: 19 Column: 1

              
import os

from absl.testing import parameterized

from keras import combinations
from keras import optimizers
from keras.mixed_precision import loss_scale_optimizer
from keras.mixed_precision import test_util as mp_test_util

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 30 Column: 1

              from keras.optimizer_v2 import optimizer_v2

import numpy as np
import tensorflow.compat.v2 as tf
# pylint: disable=g-direct-tensorflow-import
from tensorflow.python.framework import test_util
from tensorflow.python.keras.optimizer_v2 import gradient_descent as legacy_sgd

# Disable not-callable lint error, as the linter is unable to detect that

            

Reported by Pylint.

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

Line: 31 Column: 1

              
import numpy as np
import tensorflow.compat.v2 as tf
# pylint: disable=g-direct-tensorflow-import
from tensorflow.python.framework import test_util
from tensorflow.python.keras.optimizer_v2 import gradient_descent as legacy_sgd

# Disable not-callable lint error, as the linter is unable to detect that
# LossScale instances are callable.

            

Reported by Pylint.

Unable to import 'tensorflow.python.framework'
Error

Line: 32 Column: 1

              import numpy as np
import tensorflow.compat.v2 as tf
# pylint: disable=g-direct-tensorflow-import
from tensorflow.python.framework import test_util
from tensorflow.python.keras.optimizer_v2 import gradient_descent as legacy_sgd

# Disable not-callable lint error, as the linter is unable to detect that
# LossScale instances are callable.
# pylint: disable=not-callable

            

Reported by Pylint.

Unable to import 'tensorflow.python.keras.optimizer_v2'
Error

Line: 33 Column: 1

              import tensorflow.compat.v2 as tf
# pylint: disable=g-direct-tensorflow-import
from tensorflow.python.framework import test_util
from tensorflow.python.keras.optimizer_v2 import gradient_descent as legacy_sgd

# Disable not-callable lint error, as the linter is unable to detect that
# LossScale instances are callable.
# pylint: disable=not-callable


            

Reported by Pylint.

Access to a protected member _current_loss_scale of a client class
Error

Line: 602 Column: 7

                    opt = gradient_descent.SGD(learning_rate)
      loss_scale = tf.mixed_precision.experimental.DynamicLossScale(
          initial_loss_scale=4, increment_period=1, multiplier=2)
      loss_scale._current_loss_scale.assign(2)
      opt = loss_scale_optimizer.LossScaleOptimizerV1(opt, loss_scale)
      self.assertEqual(opt.initial_scale, 4)
      self.assertEqual(opt.dynamic_growth_steps, 1)
      self.evaluate(tf.compat.v1.global_variables_initializer())
      # Current loss scale is not copied so loss scale is reinitialized to 4

            

Reported by Pylint.

Unused argument 'grads'
Error

Line: 633 Column: 24

                    def __call__(self):
        return 1.

      def update(self, grads):
        return None, True

      def get_config(self):
        return {}


            

Reported by Pylint.

Method '_resource_apply_sparse' is abstract in class 'OptimizerV2' but is not overridden
Error

Line: 648 Column: 5

                  # Test learning_rate is exposed when LossScaleOptimizer wraps another
    # wrapper.

    class MyOptimizer(optimizer_v2.OptimizerV2):

      def __init__(self):
        super().__init__('MyOptimizer')
        self.inner_optimizer = adam.Adam(learning_rate=1.0)


            

Reported by Pylint.

Method '_resource_apply_dense' is abstract in class 'OptimizerV2' but is not overridden
Error

Line: 648 Column: 5

                  # Test learning_rate is exposed when LossScaleOptimizer wraps another
    # wrapper.

    class MyOptimizer(optimizer_v2.OptimizerV2):

      def __init__(self):
        super().__init__('MyOptimizer')
        self.inner_optimizer = adam.Adam(learning_rate=1.0)


            

Reported by Pylint.

TODO(b/121381184): Enable running the test in this case.
Error

Line: 726 Column: 3

                  replicas = strategy.num_replicas_in_sync
    if (isinstance(strategy, tf.distribute.MirroredStrategy) and
        not tf.executing_eagerly()):
      # TODO(b/121381184): Enable running the test in this case.
      return

    with self.test_session(), strategy.scope():
      # Build and run a simple model.
      var = tf.Variable([2.0])

            

Reported by Pylint.

keras/tests/tracking_util_test.py
724 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 18 Column: 1

              
import functools

import tensorflow.compat.v2 as tf
import os
import weakref
from tensorflow.python.eager import context
from tensorflow.python.framework import test_util
from keras import combinations

            

Reported by Pylint.

Unable to import 'tensorflow.python.eager'
Error

Line: 21 Column: 1

              import tensorflow.compat.v2 as tf
import os
import weakref
from tensorflow.python.eager import context
from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.engine import input_layer

            

Reported by Pylint.

Unable to import 'tensorflow.python.framework'
Error

Line: 22 Column: 1

              import os
import weakref
from tensorflow.python.eager import context
from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.engine import input_layer
from keras.engine import sequential

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 23 Column: 1

              import weakref
from tensorflow.python.eager import context
from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 24 Column: 1

              from tensorflow.python.eager import context
from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
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: 25 Column: 1

              from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.optimizer_v2 import adam

            

Reported by Pylint.

Unable to import 'keras.engine'
Error

Line: 26 Column: 1

              from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.optimizer_v2 import adam
from tensorflow.python.platform import tf_logging as logging

            

Reported by Pylint.

Unable to import 'keras.engine'
Error

Line: 27 Column: 1

              from keras import keras_parameterized
from keras import testing_utils
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.optimizer_v2 import adam
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training.tracking import util as trackable_utils

            

Reported by Pylint.

Unable to import 'keras.engine'
Error

Line: 28 Column: 1

              from keras import testing_utils
from keras.engine import input_layer
from keras.engine import sequential
from keras.engine import training
from keras.layers import core
from keras.optimizer_v2 import adam
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training.tracking import util as trackable_utils


            

Reported by Pylint.

Unable to import 'keras.layers'
Error

Line: 29 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.optimizer_v2 import adam
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training.tracking import util as trackable_utils



            

Reported by Pylint.

keras/layers/convolutional_test.py
701 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for convolutional layers."""

import tensorflow.compat.v2 as tf

from absl.testing import parameterized
import numpy as np

import keras

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

from absl.testing import parameterized
import numpy as np

import keras
from tensorflow.python.framework import test_util
from keras import keras_parameterized

            

Reported by Pylint.

Unable to import 'tensorflow.python.framework'
Error

Line: 23 Column: 1

              import numpy as np

import keras
from tensorflow.python.framework import test_util
from keras import keras_parameterized
from keras import testing_utils


@keras_parameterized.run_all_keras_modes

            

Reported by Pylint.

TODO(b/62340061): Support channels_first on CPU.
Error

Line: 227 Column: 3

                        'dilation_rate': (2, 2)
      }, (None, 3, 2, 2)),
      # Only runs on GPU with CUDA, channels_first is not supported on CPU.
      # TODO(b/62340061): Support channels_first on CPU.
      ('data_format', {
          'data_format': 'channels_first'
      }, None, True),
      # Only runs on GPU with CUDA, groups are not supported on CPU.
      # https://github.com/tensorflow/tensorflow/issues/29005

            

Reported by Pylint.

TODO(b/62340061): Support channels_first on CPU.
Error

Line: 350 Column: 3

                        'dilation_rate': (2, 2, 2)
      }, (None, 1, 3, 2, 2)),
      # Only runs on GPU with CUDA, channels_first is not supported on CPU.
      # TODO(b/62340061): Support channels_first on CPU.
      ('data_format', {
          'data_format': 'channels_first'
      }, None, True),
      # Only runs on GPU with CUDA, groups are not supported on CPU.
      # https://github.com/tensorflow/tensorflow/issues/29005

            

Reported by Pylint.

TODO(b/62340061): Support channels_first on CPU.
Error

Line: 506 Column: 3

                    # Only runs on GPU with CUDA, dilation_rate>1 is not supported on CPU.
      ('dilation_rate', {'dilation_rate': 2}, (None, 10, 2)),
      # Only runs on GPU with CUDA, channels_first is not supported on CPU.
      # TODO(b/62340061): Support channels_first on CPU.
      ('data_format', {'data_format': 'channels_first'}),
  )
  def test_conv1d_transpose(self, kwargs, expected_output_shape=None):
    kwargs['filters'] = 2
    kwargs['kernel_size'] = 3

            

Reported by Pylint.

TODO(b/62340061): Support channels_first on CPU.
Error

Line: 540 Column: 3

                    ('strides', {'strides': (2, 2, 2)}, (None, 11, 15, 13, 2)),
      ('dilation_rate', {'dilation_rate': (2, 2, 2)}, (None, 7, 9, 8, 2)),
      # Only runs on GPU with CUDA, channels_first is not supported on CPU.
      # TODO(b/62340061): Support channels_first on CPU.
      ('data_format', {'data_format': 'channels_first'}),
  )
  def test_conv3d_transpose(self, kwargs, expected_output_shape=None):
    kwargs['filters'] = 2
    kwargs['kernel_size'] = (3, 3, 3)

            

Reported by Pylint.

TODO(b/62340061): Support channels_first on CPU.
Error

Line: 1163 Column: 3

                        'strides': 2
      }),
      # Only runs on GPU with CUDA, channels_first is not supported on CPU.
      # TODO(b/62340061): Support channels_first on CPU.
      ('data_format', {
          'data_format': 'channels_first'
      }),
      ('depth_multiplier_1', {
          'depth_multiplier': 1

            

Reported by Pylint.

TODO(b/62340061): Support channels_first on CPU.
Error

Line: 1221 Column: 3

                    ('padding_same', {'padding': 'same'}),
      ('strides', {'strides': (2, 2)}),
      # Only runs on GPU with CUDA, channels_first is not supported on CPU.
      # TODO(b/62340061): Support channels_first on CPU.
      ('data_format', {'data_format': 'channels_first'}),
      ('depth_multiplier_1', {'depth_multiplier': 1}),
      ('depth_multiplier_2', {'depth_multiplier': 2}),
      ('dilation_rate', {'dilation_rate': (2, 2)}, (None, 3, 2, 3)),
  )

            

Reported by Pylint.

Too many lines in module (1250/1000)
Error

Line: 1 Column: 1

              # Copyright 2016 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.

keras/tests/model_subclassing_test.py
664 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for Model subclassing."""

import tensorflow.compat.v2 as tf

import copy
import os

from absl.testing import parameterized

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 22 Column: 1

              import copy
import os

from absl.testing import parameterized
import numpy as np

import keras
from tensorflow.python.framework import test_util
from keras import combinations

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 25 Column: 1

              from absl.testing import parameterized
import numpy as np

import keras
from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.tests import model_subclassing_test_util as model_util

            

Reported by Pylint.

Unable to import 'tensorflow.python.framework'
Error

Line: 26 Column: 1

              import numpy as np

import keras
from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.tests import model_subclassing_test_util as model_util
from tensorflow.python.training.tracking import data_structures

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 27 Column: 1

              
import keras
from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.tests import model_subclassing_test_util as model_util
from tensorflow.python.training.tracking import data_structures


            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 28 Column: 1

              import keras
from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.tests import model_subclassing_test_util as model_util
from tensorflow.python.training.tracking import data_structures

try:

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 29 Column: 1

              from tensorflow.python.framework import test_util
from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.tests import model_subclassing_test_util as model_util
from tensorflow.python.training.tracking import data_structures

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

            

Reported by Pylint.

Unable to import 'keras.tests'
Error

Line: 30 Column: 1

              from keras import combinations
from keras import keras_parameterized
from keras import testing_utils
from keras.tests import model_subclassing_test_util as model_util
from tensorflow.python.training.tracking import data_structures

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

            

Reported by Pylint.

Unable to import 'tensorflow.python.training.tracking'
Error

Line: 31 Column: 1

              from keras import keras_parameterized
from keras import testing_utils
from keras.tests import model_subclassing_test_util as model_util
from tensorflow.python.training.tracking import data_structures

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

            

Reported by Pylint.

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

Line: 34 Column: 1

              from tensorflow.python.training.tracking import data_structures

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


@keras_parameterized.run_all_keras_modes

            

Reported by Pylint.

keras/saving/saved_model/load.py
661 issues
Unable to import 'keras'
Error

Line: 21 Column: 1

              import re
import types

from keras import backend
from keras import regularizers
from keras.engine import input_spec
from keras.optimizer_v2 import optimizer_v2
from keras.protobuf import saved_metadata_pb2
from keras.protobuf import versions_pb2

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 22 Column: 1

              import types

from keras import backend
from keras import regularizers
from keras.engine import input_spec
from keras.optimizer_v2 import optimizer_v2
from keras.protobuf import saved_metadata_pb2
from keras.protobuf import versions_pb2
from keras.saving import saving_utils

            

Reported by Pylint.

Unable to import 'keras.engine'
Error

Line: 23 Column: 1

              
from keras import backend
from keras import regularizers
from keras.engine import input_spec
from keras.optimizer_v2 import optimizer_v2
from keras.protobuf import saved_metadata_pb2
from keras.protobuf import versions_pb2
from keras.saving import saving_utils
from keras.saving.saved_model import constants

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 24 Column: 1

              from keras import backend
from keras import regularizers
from keras.engine import input_spec
from keras.optimizer_v2 import optimizer_v2
from keras.protobuf import saved_metadata_pb2
from keras.protobuf import versions_pb2
from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import json_utils

            

Reported by Pylint.

Unable to import 'keras.protobuf'
Error

Line: 25 Column: 1

              from keras import regularizers
from keras.engine import input_spec
from keras.optimizer_v2 import optimizer_v2
from keras.protobuf import saved_metadata_pb2
from keras.protobuf import versions_pb2
from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import json_utils
from keras.saving.saved_model import utils

            

Reported by Pylint.

Unable to import 'keras.protobuf'
Error

Line: 26 Column: 1

              from keras.engine import input_spec
from keras.optimizer_v2 import optimizer_v2
from keras.protobuf import saved_metadata_pb2
from keras.protobuf import versions_pb2
from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import json_utils
from keras.saving.saved_model import utils
from keras.saving.saved_model.serialized_attributes import CommonEndpoints

            

Reported by Pylint.

Unable to import 'keras.saving'
Error

Line: 27 Column: 1

              from keras.optimizer_v2 import optimizer_v2
from keras.protobuf import saved_metadata_pb2
from keras.protobuf import versions_pb2
from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import json_utils
from keras.saving.saved_model import utils
from keras.saving.saved_model.serialized_attributes import CommonEndpoints
from keras.utils import generic_utils

            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 28 Column: 1

              from keras.protobuf import saved_metadata_pb2
from keras.protobuf import versions_pb2
from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import json_utils
from keras.saving.saved_model import utils
from keras.saving.saved_model.serialized_attributes import CommonEndpoints
from keras.utils import generic_utils
from keras.utils import metrics_utils

            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 29 Column: 1

              from keras.protobuf import versions_pb2
from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import json_utils
from keras.saving.saved_model import utils
from keras.saving.saved_model.serialized_attributes import CommonEndpoints
from keras.utils import generic_utils
from keras.utils import metrics_utils
from keras.utils.generic_utils import LazyLoader

            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 30 Column: 1

              from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import json_utils
from keras.saving.saved_model import utils
from keras.saving.saved_model.serialized_attributes import CommonEndpoints
from keras.utils import generic_utils
from keras.utils import metrics_utils
from keras.utils.generic_utils import LazyLoader
import tensorflow.compat.v1.logging as logging

            

Reported by Pylint.