The following issues were found

keras/engine/compile_utils.py
422 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Utilities for `Model.compile`."""

import tensorflow.compat.v2 as tf

import copy
from keras import losses as losses_mod
from keras import metrics as metrics_mod
from keras.utils import generic_utils

            

Reported by Pylint.

Parameters differ from overridden '_should_broadcast' method
Error

Line: 283 Column: 3

                  loss._allow_sum_over_batch_size = True  # pylint: disable=protected-access
    return loss

  def _should_broadcast(self, obj):
    return not tf.nest.is_nested(obj)

  def _copy_object(self, obj):
    return obj  # Losses don't need to be copied.


            

Reported by Pylint.

Parameters differ from overridden 'build' method
Error

Line: 339 Column: 3

                    return None
    return tf.nest.flatten(self._weighted_metrics)

  def build(self, y_pred, y_true):
    """One-time setup of metric objects."""
    super(MetricsContainer, self).build(y_pred)

    self._metrics = self._maybe_broadcast_to_outputs(y_pred, self._metrics)
    self._metrics = self._conform_to_outputs(y_pred, self._metrics)

            

Reported by Pylint.

Attribute '_metrics_in_order' defined outside __init__
Error

Line: 423 Column: 5

              
  def _create_ordered_metrics(self):
    """Cache the flat order needed when returning metrics, for backwards compat."""
    self._metrics_in_order = []
    for output_metrics, output_weighted_metrics in zip(self._metrics,
                                                       self._weighted_metrics):
      for m in tf.nest.flatten(output_metrics):
        if m is not None:
          self._metrics_in_order.append(m)

            

Reported by Pylint.

Parameters differ from overridden '_should_broadcast' method
Error

Line: 546 Column: 3

              
    return metric_obj

  def _should_broadcast(self, obj):
    # e.g. 'mse'.
    if not tf.nest.is_nested(obj):
      return True
    # e.g. ['mse'] or ['mse', 'mae'].
    return (isinstance(obj, (list, tuple)) and

            

Reported by Pylint.

Possible unbalanced tuple unpacking with sequence defined at line 201 of keras.utils.losses_utils: left side has 3 label(s), right side has 2 value(s)
Error

Line: 704 Column: 7

                if mask is not None:
    mask = tf.cast(mask, y_p.dtype)
    if sw is not None:
      mask, _, sw = (
          losses_utils.squeeze_or_expand_dimensions(mask, sample_weight=sw))
      sw *= mask
    else:
      sw = mask
  return sw

            

Reported by Pylint.

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

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

import copy
from keras import losses as losses_mod
from keras import metrics as metrics_mod
from keras.utils import generic_utils
from keras.utils import losses_utils
from keras.utils import tf_utils

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 27 Column: 1

              from keras.utils import tf_utils


class Container:
  """Base Container class."""

  def __init__(self, output_names=None):
    self._output_names = output_names


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 28 Column: 1

              

class Container:
  """Base Container class."""

  def __init__(self, output_names=None):
    self._output_names = output_names

  def build(self, y_pred):

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              class Container:
  """Base Container class."""

  def __init__(self, output_names=None):
    self._output_names = output_names

  def build(self, y_pred):
    if self._output_names is None:
      # In Subclass API, output names like 'output_1' are used for

            

Reported by Pylint.

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

Line: 15 Column: 1

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

import tensorflow.compat.v2 as tf

import uuid

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 18 Column: 1

              # pylint: disable=g-classes-have-attributes
"""Recurrent layers for TF 2."""

import tensorflow.compat.v2 as tf

import uuid
from tensorflow.python.eager.context import get_device_name
from keras import activations
from keras import backend

            

Reported by Pylint.

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

Line: 21 Column: 1

              import tensorflow.compat.v2 as tf

import uuid
from tensorflow.python.eager.context import get_device_name
from keras import activations
from keras import backend
from keras.engine.input_spec import InputSpec
from keras.layers import recurrent
from tensorflow.python.platform import tf_logging as logging

            

Reported by Pylint.

Unable to import 'tensorflow.python.platform'
Error

Line: 26 Column: 1

              from keras import backend
from keras.engine.input_spec import InputSpec
from keras.layers import recurrent
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export


# The following string constants are used by Defun approach for unified backend
# of LSTM and GRU.

            

Reported by Pylint.

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

Line: 27 Column: 1

              from keras.engine.input_spec import InputSpec
from keras.layers import recurrent
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export


# The following string constants are used by Defun approach for unified backend
# of LSTM and GRU.
_FUNCTION_API_NAME_ATTRIBUTE = 'api_implements'

            

Reported by Pylint.

TODO(b/169707691): The wrapper can be removed if TFLite doesn't need to rely
Error

Line: 56 Column: 3

                return False


# TODO(b/169707691): The wrapper can be removed if TFLite doesn't need to rely
# on supportive attributes from LSTM/GRU.
class _DefunWrapper:
  """A wrapper with no deep copy of the Defun in LSTM/GRU layer."""

  def __init__(self, time_major, go_backwards, layer_name):

            

Reported by Pylint.

TODO(b/156447398) Investigate why the cuDNN kernel fails with ragged
Error

Line: 420 Column: 3

                  input_shape = backend.int_shape(inputs)
    timesteps = input_shape[0] if self.time_major else input_shape[1]

    # TODO(b/156447398) Investigate why the cuDNN kernel fails with ragged
    # inputs.
    if is_ragged_input or not self._could_use_gpu_kernel:
      kwargs = {'training': training}
      self._maybe_reset_cell_dropout_mask(self.cell)


            

Reported by Pylint.

TODO(b/156447398) Investigate why the cuDNN kernel fails with ragged
Error

Line: 1148 Column: 3

                  input_shape = backend.int_shape(inputs)
    timesteps = input_shape[0] if self.time_major else input_shape[1]

    # TODO(b/156447398) Investigate why the cuDNN kernel fails with ragged
    # inputs.
    if is_ragged_input or not self._could_use_gpu_kernel:
      # Fall back to use the normal LSTM.
      kwargs = {'training': training}
      self._maybe_reset_cell_dropout_mask(self.cell)

            

Reported by Pylint.

Too many lines in module (1785/1000)
Error

Line: 1 Column: 1

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

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

Line: 20 Column: 1

              
import tensorflow.compat.v2 as tf

import uuid
from tensorflow.python.eager.context import get_device_name
from keras import activations
from keras import backend
from keras.engine.input_spec import InputSpec
from keras.layers import recurrent

            

Reported by Pylint.

keras/layers/preprocessing/integer_lookup_test.py
417 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for Keras text vectorization preprocessing layer."""

import tensorflow.compat.v2 as tf

import gc
import itertools
import os
import random

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 24 Column: 1

              import os
import random

from absl.testing import parameterized
import numpy as np

import keras
from keras import keras_parameterized
from keras import testing_utils

            

Reported by Pylint.

TODO(rachelim): `model.predict` predicts the result on each
Error

Line: 85 Column: 3

              
    if use_dataset:
      # Keras APIs expect batched datasets.
      # TODO(rachelim): `model.predict` predicts the result on each
      # dataset batch separately, then tries to concatenate the results
      # together. When the results have different shapes on the non-concat
      # axis (which can happen in the output_mode = INT case for
      # IntegerLookup), the concatenation fails. In real use cases, this may
      # not be an issue because users are likely to pipe the preprocessing layer

            

Reported by Pylint.

TODO(b/149526183): Can't clear session when TF2 is disabled.
Error

Line: 602 Column: 3

              
    # Delete the session and graph to ensure that the loaded model is generated
    # from scratch.
    # TODO(b/149526183): Can't clear session when TF2 is disabled.
    if tf.__internal__.tf2.enabled():
      keras.backend.clear_session()

    loaded_model = keras.models.load_model(
        output_path,

            

Reported by Pylint.

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

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

import gc
import itertools
import os
import random

from absl.testing import parameterized

            

Reported by Pylint.

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

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf

import gc
import itertools
import os
import random

from absl.testing import parameterized
import numpy as np

            

Reported by Pylint.

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

Line: 21 Column: 1

              
import gc
import itertools
import os
import random

from absl.testing import parameterized
import numpy as np


            

Reported by Pylint.

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

Line: 22 Column: 1

              import gc
import itertools
import os
import random

from absl.testing import parameterized
import numpy as np

import keras

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 35 Column: 1

              

def _get_end_to_end_test_cases():
  test_cases = (
      {
          "testcase_name":
              "test_ints_soft_vocab_cap",
          # Create an array where 1138 is the most frequent term, followed by
          # 1729, then 725, then 42. This ensures that the vocab accumulator

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 58 Column: 1

                            tf.int64
      },)

  crossed_test_cases = []
  # Cross above test cases with use_dataset in (True, False)
  for use_dataset in (True, False):
    for case in test_cases:
      case = case.copy()
      if use_dataset:

            

Reported by Pylint.

keras/distribute/custom_training_loop_models_test.py
413 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for custom training loops."""

import tensorflow.compat.v2 as tf

import os

from absl.testing import parameterized
import numpy as np

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 21 Column: 1

              
import os

from absl.testing import parameterized
import numpy as np

import keras
from keras.distribute import strategy_combinations
from keras.layers import core

            

Reported by Pylint.

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

Line: 108 Column: 7

                def test_keras_subclass_model_optimizer_run(self, distribution):
    def get_subclass_model():

      class KerasSubclassModel(keras.Model):

        def __init__(self):
          super(KerasSubclassModel, self).__init__()
          self.l = keras.layers.Dense(4, name="dense")


            

Reported by Pylint.

Parameters differ from overridden 'call' method
Error

Line: 114 Column: 9

                        super(KerasSubclassModel, self).__init__()
          self.l = keras.layers.Dense(4, name="dense")

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

      return KerasSubclassModel()
    dataset = _get_dataset()
    input_iterator = iter(distribution.experimental_distribute_dataset(dataset))

            

Reported by Pylint.

Attribute 'kernel' defined outside __init__
Error

Line: 490 Column: 9

                      self.num_outputs = num_outputs

      def build(self, input_shape):
        self.kernel = self.add_variable(
            "kernel", shape=[int(input_shape[-1]), self.num_outputs])

      @tf.function(jit_compile=True)
      def call(self, inputs):
        return tf.matmul(inputs, self.kernel)

            

Reported by Pylint.

Parameters differ from overridden 'call' method
Error

Line: 494 Column: 7

                          "kernel", shape=[int(input_shape[-1]), self.num_outputs])

      @tf.function(jit_compile=True)
      def call(self, inputs):
        return tf.matmul(inputs, self.kernel)

    with distribution.scope():
      x = keras.layers.Input(shape=(3,))
      y = CustomDense(4)(x)

            

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 absl.testing import parameterized
import numpy as np

import keras

            

Reported by Pylint.

Missing class docstring
Error

Line: 30 Column: 1

              from keras.optimizer_v2 import gradient_descent


class CustomModel(tf.Module):

  def __init__(self, name=None):
    super(CustomModel, self).__init__(name=name)
    with self.name_scope:
      self._layers = [

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 30 Column: 1

              from keras.optimizer_v2 import gradient_descent


class CustomModel(tf.Module):

  def __init__(self, name=None):
    super(CustomModel, self).__init__(name=name)
    with self.name_scope:
      self._layers = [

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              
class CustomModel(tf.Module):

  def __init__(self, name=None):
    super(CustomModel, self).__init__(name=name)
    with self.name_scope:
      self._layers = [
          keras.layers.Dense(4, name="dense"),
      ]

            

Reported by Pylint.

keras/optimizer_v2/rmsprop_test.py
409 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for rmsprop."""

import tensorflow.compat.v2 as tf

import copy
import itertools
import math


            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 23 Column: 1

              import itertools
import math

from absl.testing import parameterized
import numpy as np
from tensorflow.python.framework import test_util
from keras import combinations
from keras import testing_utils
from keras.optimizer_v2 import learning_rate_schedule

            

Reported by Pylint.

Unable to import 'tensorflow.python.framework'
Error

Line: 25 Column: 1

              
from absl.testing import parameterized
import numpy as np
from tensorflow.python.framework import test_util
from keras import combinations
from keras import testing_utils
from keras.optimizer_v2 import learning_rate_schedule
from keras.optimizer_v2 import rmsprop


            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 26 Column: 1

              from absl.testing import parameterized
import numpy as np
from tensorflow.python.framework import test_util
from keras import combinations
from keras import testing_utils
from keras.optimizer_v2 import learning_rate_schedule
from keras.optimizer_v2 import rmsprop

_DATA_TYPES = [

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 27 Column: 1

              import numpy as np
from tensorflow.python.framework import test_util
from keras import combinations
from keras import testing_utils
from keras.optimizer_v2 import learning_rate_schedule
from keras.optimizer_v2 import rmsprop

_DATA_TYPES = [
    tf.half, tf.float32, tf.float64, tf.complex64,

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 28 Column: 1

              from tensorflow.python.framework import test_util
from keras import combinations
from keras import testing_utils
from keras.optimizer_v2 import learning_rate_schedule
from keras.optimizer_v2 import rmsprop

_DATA_TYPES = [
    tf.half, tf.float32, tf.float64, tf.complex64,
    tf.complex128

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 29 Column: 1

              from keras import combinations
from keras import testing_utils
from keras.optimizer_v2 import learning_rate_schedule
from keras.optimizer_v2 import rmsprop

_DATA_TYPES = [
    tf.half, tf.float32, tf.float64, tf.complex64,
    tf.complex128
]

            

Reported by Pylint.

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

Line: 95 Column: 3

                  return var_t, mg_t, rms_t, mom_t

  def testDense(self):
    # TODO(tanzheny, omalleyt): Fix test in eager mode.
    for (dtype, learning_rate, rho, momentum, epsilon, centered) in _TESTPARAMS:
      with tf.compat.v1.get_default_graph().as_default(), testing_utils.use_gpu():
        # Initialize variables for numpy implementation.
        var0_np = np.array([1.0, 2.0], dtype=dtype.as_numpy_dtype)
        grads0_np = np.array([0.1, 0.2], dtype=dtype.as_numpy_dtype)

            

Reported by Pylint.

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

Line: 172 Column: 3

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

  def testDenseWithLearningRateDecay(self):
    # TODO(tanzheny, omalleyt): Fix test in eager mode.
    with tf.Graph().as_default():
      var0_np = np.array([1.0, 2.0])
      grads0_np = np.array([0.1, 0.2])
      var1_np = np.array([3.0, 4.0])
      grads1_np = np.array([0.01, 0.2])

            

Reported by Pylint.

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

Line: 244 Column: 3

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

  def testDenseWithLearningRateInverseTimeDecay(self):
    # TODO(tanzheny, omalleyt): Fix test in eager mode.
    with tf.Graph().as_default():
      var0_np = np.array([1.0, 2.0])
      grads0_np = np.array([0.1, 0.2])
      var1_np = np.array([3.0, 4.0])
      grads1_np = np.array([0.01, 0.2])

            

Reported by Pylint.

keras/optimizer_v2/legacy_learning_rate_decay_test.py
401 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Functional test for learning rate decay."""

import tensorflow.compat.v2 as tf

import math
from keras import combinations
from keras import keras_parameterized
from keras.optimizer_v2 import legacy_learning_rate_decay as learning_rate_decay

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf

import math
from keras import combinations
from keras import keras_parameterized
from keras.optimizer_v2 import legacy_learning_rate_decay as learning_rate_decay


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

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 21 Column: 1

              
import math
from keras import combinations
from keras import keras_parameterized
from keras.optimizer_v2 import legacy_learning_rate_decay as learning_rate_decay


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

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 22 Column: 1

              import math
from keras import combinations
from keras import keras_parameterized
from keras.optimizer_v2 import legacy_learning_rate_decay as learning_rate_decay


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


            

Reported by Pylint.

Unused legacy_learning_rate_decay imported from keras.optimizer_v2 as learning_rate_decay
Error

Line: 22 Column: 1

              import math
from keras import combinations
from keras import keras_parameterized
from keras.optimizer_v2 import legacy_learning_rate_decay as learning_rate_decay


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


            

Reported by Pylint.

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

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

import math
from keras import combinations
from keras import keras_parameterized
from keras.optimizer_v2 import legacy_learning_rate_decay as learning_rate_decay



            

Reported by Pylint.

Missing class docstring
Error

Line: 26 Column: 1

              

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

  def testContinuous(self):
    self.evaluate(tf.compat.v1.global_variables_initializer())
    step = 5
    decayed_lr = tf.compat.v1.train.exponential_decay(0.05, step, 10, 0.96)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 28 Column: 1

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

  def testContinuous(self):
    self.evaluate(tf.compat.v1.global_variables_initializer())
    step = 5
    decayed_lr = tf.compat.v1.train.exponential_decay(0.05, step, 10, 0.96)
    expected = .05 * 0.96**(5.0 / 10.0)
    self.assertAllClose(self.evaluate(decayed_lr), expected, 1e-6)

            

Reported by Pylint.

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

Line: 28 Column: 3

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

  def testContinuous(self):
    self.evaluate(tf.compat.v1.global_variables_initializer())
    step = 5
    decayed_lr = tf.compat.v1.train.exponential_decay(0.05, step, 10, 0.96)
    expected = .05 * 0.96**(5.0 / 10.0)
    self.assertAllClose(self.evaluate(decayed_lr), expected, 1e-6)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 3

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

  def testContinuous(self):
    self.evaluate(tf.compat.v1.global_variables_initializer())
    step = 5
    decayed_lr = tf.compat.v1.train.exponential_decay(0.05, step, 10, 0.96)
    expected = .05 * 0.96**(5.0 / 10.0)
    self.assertAllClose(self.evaluate(decayed_lr), expected, 1e-6)

            

Reported by Pylint.

keras/layers/merge_test.py
393 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for merge 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 keras import backend
from keras import combinations

            

Reported by Pylint.

Unused argument 'layer'
Error

Line: 231 Column: 42

                               keras.layers.Multiply, keras.layers.Minimum,
                 keras.layers.Maximum, keras.layers.Average,
                 keras.layers.Concatenate]))
  def test_merge_with_ragged_input(self, layer):
    ragged_data = tf.ragged.constant(
        [[1., 1., 1.], [1., 1.], [1., 1., 1., 1.]], ragged_rank=1)
    dense_data = ragged_data.to_tensor()
    input1 = keras.Input(shape=(None,), ragged=True)
    input2 = keras.Input(shape=(None,), ragged=True)

            

Reported by Pylint.

Missing class docstring
Error

Line: 30 Column: 1

              

@keras_parameterized.run_all_keras_modes
class MergeLayersTest(keras_parameterized.TestCase):

  def test_merge_add(self):
    i1 = keras.layers.Input(shape=(4, 5))
    i2 = keras.layers.Input(shape=(4, 5))
    i3 = keras.layers.Input(shape=(4, 5))

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              @keras_parameterized.run_all_keras_modes
class MergeLayersTest(keras_parameterized.TestCase):

  def test_merge_add(self):
    i1 = keras.layers.Input(shape=(4, 5))
    i2 = keras.layers.Input(shape=(4, 5))
    i3 = keras.layers.Input(shape=(4, 5))

    add_layer = keras.layers.Add()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 32 Column: 3

              @keras_parameterized.run_all_keras_modes
class MergeLayersTest(keras_parameterized.TestCase):

  def test_merge_add(self):
    i1 = keras.layers.Input(shape=(4, 5))
    i2 = keras.layers.Input(shape=(4, 5))
    i3 = keras.layers.Input(shape=(4, 5))

    add_layer = keras.layers.Add()

            

Reported by Pylint.

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

Line: 33 Column: 5

              class MergeLayersTest(keras_parameterized.TestCase):

  def test_merge_add(self):
    i1 = keras.layers.Input(shape=(4, 5))
    i2 = keras.layers.Input(shape=(4, 5))
    i3 = keras.layers.Input(shape=(4, 5))

    add_layer = keras.layers.Add()
    o = add_layer([i1, i2, i3])

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 33 Column: 1

              class MergeLayersTest(keras_parameterized.TestCase):

  def test_merge_add(self):
    i1 = keras.layers.Input(shape=(4, 5))
    i2 = keras.layers.Input(shape=(4, 5))
    i3 = keras.layers.Input(shape=(4, 5))

    add_layer = keras.layers.Add()
    o = add_layer([i1, i2, i3])

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 34 Column: 1

              
  def test_merge_add(self):
    i1 = keras.layers.Input(shape=(4, 5))
    i2 = keras.layers.Input(shape=(4, 5))
    i3 = keras.layers.Input(shape=(4, 5))

    add_layer = keras.layers.Add()
    o = add_layer([i1, i2, i3])
    self.assertListEqual(o.shape.as_list(), [None, 4, 5])

            

Reported by Pylint.

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

Line: 34 Column: 5

              
  def test_merge_add(self):
    i1 = keras.layers.Input(shape=(4, 5))
    i2 = keras.layers.Input(shape=(4, 5))
    i3 = keras.layers.Input(shape=(4, 5))

    add_layer = keras.layers.Add()
    o = add_layer([i1, i2, i3])
    self.assertListEqual(o.shape.as_list(), [None, 4, 5])

            

Reported by Pylint.

keras/optimizer_v2/adagrad_test.py
381 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Functional tests for aggregate operations."""

import tensorflow.compat.v2 as tf

import copy

from absl.testing import parameterized
import numpy as np

            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 21 Column: 1

              
import copy

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


            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 23 Column: 1

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

_DATA_TYPES = [
    tf.half, tf.float32, tf.float64, tf.complex64,

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 24 Column: 1

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

_DATA_TYPES = [
    tf.half, tf.float32, tf.float64, tf.complex64,
    tf.complex128

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 25 Column: 1

              import numpy as np
from keras import combinations
from keras.optimizer_v2 import adagrad
from keras.optimizer_v2 import learning_rate_schedule

_DATA_TYPES = [
    tf.half, tf.float32, tf.float64, tf.complex64,
    tf.complex128
]

            

Reported by Pylint.

Bad option value 'g-long-lambda'
Error

Line: 414 Column: 1

                  with tf.Graph().as_default():
      for dtype in _DATA_TYPES:
        var_repeated = tf.Variable([1.0, 2.0], dtype=dtype)
        loss_repeated = lambda: tf.reduce_sum(  # pylint: disable=g-long-lambda
            tf.compat.v1.nn.embedding_lookup(var_repeated, [0, 0]))  # pylint: disable=cell-var-from-loop
        var_aggregated = tf.Variable([1.0, 2.0], dtype=dtype)
        loss_aggregated = lambda: 2 * tf.reduce_sum(  # pylint: disable=g-long-lambda
            tf.compat.v1.nn.embedding_lookup(var_aggregated, [0]))  # pylint: disable=cell-var-from-loop
        update_op_repeated = adagrad.Adagrad(2.0).minimize(

            

Reported by Pylint.

Bad option value 'g-long-lambda'
Error

Line: 417 Column: 1

                      loss_repeated = lambda: tf.reduce_sum(  # pylint: disable=g-long-lambda
            tf.compat.v1.nn.embedding_lookup(var_repeated, [0, 0]))  # pylint: disable=cell-var-from-loop
        var_aggregated = tf.Variable([1.0, 2.0], dtype=dtype)
        loss_aggregated = lambda: 2 * tf.reduce_sum(  # pylint: disable=g-long-lambda
            tf.compat.v1.nn.embedding_lookup(var_aggregated, [0]))  # pylint: disable=cell-var-from-loop
        update_op_repeated = adagrad.Adagrad(2.0).minimize(
            loss_repeated, var_list=[var_repeated])
        update_op_aggregated = adagrad.Adagrad(2.0).minimize(
            loss_aggregated, var_list=[var_aggregated])

            

Reported by Pylint.

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

Line: 241 Column: 3

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

  def testMinimizeSparseResourceVariable(self):
    # TODO(tanzheny, omalleyt): Fix test in eager mode.
    with tf.Graph().as_default():
      for dtype in _DATA_TYPES:
        var0 = tf.Variable([[1.0, 2.0], [3.0, 4.0]], dtype=dtype)
        x = tf.constant([[4.0], [5.0]], dtype=dtype)


            

Reported by Pylint.

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

Line: 264 Column: 3

                                                         atol=0.01)

  def testTensorLearningRate(self):
    # TODO(tanzheny, omalleyt): Fix test in eager mode.
    with tf.Graph().as_default():
      for dtype in _DATA_TYPES:
        var0_np = np.array([1.0, 2.0], dtype=dtype.as_numpy_dtype)
        var1_np = np.array([3.0, 4.0], dtype=dtype.as_numpy_dtype)
        grads0_np = np.array([0.1, 0.1], dtype=dtype.as_numpy_dtype)

            

Reported by Pylint.

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

Line: 297 Column: 3

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

  def testSparseBasic(self):
    # TODO(tanzheny, omalleyt): Fix test in eager mode.
    with tf.Graph().as_default():
      for dtype in _DATA_TYPES:
        var0_np = np.array([1.0, 1.0, 2.0], dtype=dtype.as_numpy_dtype)
        grads0_np = np.array([0.1, 0, 0.1], dtype=dtype.as_numpy_dtype)
        var1_np = np.array([3.0, 3.0, 4.0], dtype=dtype.as_numpy_dtype)

            

Reported by Pylint.

keras/optimizer_v2/learning_rate_schedule_test.py
379 issues
Unable to import 'absl.testing'
Error

Line: 19 Column: 1

              
import math

from absl.testing import parameterized

from keras import combinations
from keras.optimizer_v2 import gradient_descent
from keras.optimizer_v2 import learning_rate_schedule
import numpy as np

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 21 Column: 1

              
from absl.testing import parameterized

from keras import combinations
from keras.optimizer_v2 import gradient_descent
from keras.optimizer_v2 import learning_rate_schedule
import numpy as np

import tensorflow.compat.v2 as tf

            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 22 Column: 1

              from absl.testing import parameterized

from keras import combinations
from keras.optimizer_v2 import gradient_descent
from keras.optimizer_v2 import learning_rate_schedule
import numpy as np

import tensorflow.compat.v2 as tf


            

Reported by Pylint.

Unable to import 'keras.optimizer_v2'
Error

Line: 23 Column: 1

              
from keras import combinations
from keras.optimizer_v2 import gradient_descent
from keras.optimizer_v2 import learning_rate_schedule
import numpy as np

import tensorflow.compat.v2 as tf



            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 26 Column: 1

              from keras.optimizer_v2 import learning_rate_schedule
import numpy as np

import tensorflow.compat.v2 as tf


def _maybe_serialized(lr_decay, serialize_and_deserialize):
  if serialize_and_deserialize:
    serialized = learning_rate_schedule.serialize(lr_decay)

            

Reported by Pylint.

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

Line: 72 Column: 3

                    self.assertAllClose(self.evaluate(decayed_lr(step)), expected, 1e-6)

  def testVariables(self, serialize):
    # TODO(tanzheny, omalleyt): Fix test in eager mode.
    with tf.Graph().as_default():
      step = tf.Variable(1)
      assign_1 = step.assign(1)
      assign_2 = step.assign(2)
      assign_100 = step.assign(100)

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 30 Column: 3

              

def _maybe_serialized(lr_decay, serialize_and_deserialize):
  if serialize_and_deserialize:
    serialized = learning_rate_schedule.serialize(lr_decay)
    return learning_rate_schedule.deserialize(serialized)
  else:
    return lr_decay


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              

def _maybe_serialized(lr_decay, serialize_and_deserialize):
  if serialize_and_deserialize:
    serialized = learning_rate_schedule.serialize(lr_decay)
    return learning_rate_schedule.deserialize(serialized)
  else:
    return lr_decay


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 31 Column: 1

              
def _maybe_serialized(lr_decay, serialize_and_deserialize):
  if serialize_and_deserialize:
    serialized = learning_rate_schedule.serialize(lr_decay)
    return learning_rate_schedule.deserialize(serialized)
  else:
    return lr_decay



            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 32 Column: 1

              def _maybe_serialized(lr_decay, serialize_and_deserialize):
  if serialize_and_deserialize:
    serialized = learning_rate_schedule.serialize(lr_decay)
    return learning_rate_schedule.deserialize(serialized)
  else:
    return lr_decay


@combinations.generate(combinations.combine(serialize=[False, True],

            

Reported by Pylint.

keras/tests/add_loss_correctness_test.py
372 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests add_loss API correctness."""

import tensorflow.compat.v2 as tf

import numpy as np
from keras import Input
from keras import keras_parameterized
from keras import layers

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf

import numpy as np
from keras import Input
from keras import keras_parameterized
from keras import layers
from keras import losses
from keras import Model
from keras import optimizer_v2

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 21 Column: 1

              
import numpy as np
from keras import Input
from keras import keras_parameterized
from keras import layers
from keras import losses
from keras import Model
from keras import optimizer_v2
from keras import Sequential

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 22 Column: 1

              import numpy as np
from keras import Input
from keras import keras_parameterized
from keras import layers
from keras import losses
from keras import Model
from keras import optimizer_v2
from keras import Sequential
from keras import testing_utils

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 23 Column: 1

              from keras import Input
from keras import keras_parameterized
from keras import layers
from keras import losses
from keras import Model
from keras import optimizer_v2
from keras import Sequential
from keras import testing_utils
from tensorflow.python.platform import tf_logging as logging

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 24 Column: 1

              from keras import keras_parameterized
from keras import layers
from keras import losses
from keras import Model
from keras import optimizer_v2
from keras import Sequential
from keras import testing_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training.rmsprop import RMSPropOptimizer

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 25 Column: 1

              from keras import layers
from keras import losses
from keras import Model
from keras import optimizer_v2
from keras import Sequential
from keras import testing_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training.rmsprop import RMSPropOptimizer


            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 26 Column: 1

              from keras import losses
from keras import Model
from keras import optimizer_v2
from keras import Sequential
from keras import testing_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training.rmsprop import RMSPropOptimizer

MAE = losses.MeanAbsoluteError

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 27 Column: 1

              from keras import Model
from keras import optimizer_v2
from keras import Sequential
from keras import testing_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training.rmsprop import RMSPropOptimizer

MAE = losses.MeanAbsoluteError
mae = losses.mean_absolute_error

            

Reported by Pylint.

Unable to import 'tensorflow.python.platform'
Error

Line: 28 Column: 1

              from keras import optimizer_v2
from keras import Sequential
from keras import testing_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training.rmsprop import RMSPropOptimizer

MAE = losses.MeanAbsoluteError
mae = losses.mean_absolute_error


            

Reported by Pylint.