The following issues were found
keras/preprocessing/image_test.py
290 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests for image preprocessing utils."""
import tensorflow.compat.v2 as tf
import os
import shutil
import tempfile
Reported by Pylint.
Line: 23
Column: 1
import shutil
import tempfile
from absl.testing import parameterized
import numpy as np
from keras import keras_parameterized
from keras import layers
from keras.engine import sequential
from keras.preprocessing import image as preprocessing_image
Reported by Pylint.
Line: 31
Column: 1
from keras.preprocessing import image as preprocessing_image
try:
import PIL # pylint:disable=g-import-not-at-top
except ImportError:
PIL = None
def _generate_test_images():
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
import os
import shutil
import tempfile
from absl.testing import parameterized
import numpy as np
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
import os
import shutil
import tempfile
from absl.testing import parameterized
import numpy as np
from keras import keras_parameterized
Reported by Pylint.
Line: 21
Column: 1
import os
import shutil
import tempfile
from absl.testing import parameterized
import numpy as np
from keras import keras_parameterized
from keras import layers
Reported by Pylint.
Line: 31
Column: 1
from keras.preprocessing import image as preprocessing_image
try:
import PIL # pylint:disable=g-import-not-at-top
except ImportError:
PIL = None
def _generate_test_images():
Reported by Pylint.
Line: 33
Column: 1
try:
import PIL # pylint:disable=g-import-not-at-top
except ImportError:
PIL = None
def _generate_test_images():
img_w = img_h = 20
rgb_images = []
Reported by Pylint.
Line: 37
Column: 1
def _generate_test_images():
img_w = img_h = 20
rgb_images = []
gray_images = []
for _ in range(8):
bias = np.random.rand(img_w, img_h, 1) * 64
variance = np.random.rand(img_w, img_h, 1) * (255 - 64)
Reported by Pylint.
Line: 38
Column: 1
def _generate_test_images():
img_w = img_h = 20
rgb_images = []
gray_images = []
for _ in range(8):
bias = np.random.rand(img_w, img_h, 1) * 64
variance = np.random.rand(img_w, img_h, 1) * (255 - 64)
imarray = np.random.rand(img_w, img_h, 3) * variance + bias
Reported by Pylint.
keras/initializers/initializers_v2.py
289 issues
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
"""Keras initializers for TF 2."""
# pylint: disable=g-classes-have-attributes
import math
from keras import backend
import tensorflow.compat.v2 as tf
from tensorflow.python.ops import stateless_random_ops
Reported by Pylint.
Line: 20
Column: 1
import math
from keras import backend
import tensorflow.compat.v2 as tf
from tensorflow.python.ops import stateless_random_ops
from tensorflow.python.util.tf_export import keras_export
_PARTITION_SHAPE = 'partition_shape'
_PARTITION_OFFSET = 'partition_offset'
Reported by Pylint.
Line: 21
Column: 1
import math
from keras import backend
import tensorflow.compat.v2 as tf
from tensorflow.python.ops import stateless_random_ops
from tensorflow.python.util.tf_export import keras_export
_PARTITION_SHAPE = 'partition_shape'
_PARTITION_OFFSET = 'partition_offset'
Reported by Pylint.
Line: 22
Column: 1
from keras import backend
import tensorflow.compat.v2 as tf
from tensorflow.python.ops import stateless_random_ops
from tensorflow.python.util.tf_export import keras_export
_PARTITION_SHAPE = 'partition_shape'
_PARTITION_OFFSET = 'partition_offset'
Reported by Pylint.
Line: 1
Column: 1
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
Reported by Pylint.
Line: 30
Column: 1
@keras_export('keras.initializers.Initializer')
class Initializer:
"""Initializer base class: all Keras initializers inherit from this class.
Initializers should implement a `__call__` method with the following
signature:
```python
Reported by Pylint.
Line: 70
Column: 1
works fine.
"""
def __call__(self, shape, dtype=None, **kwargs):
"""Returns a tensor object initialized as specified by the initializer.
Args:
shape: Shape of the tensor.
dtype: Optional dtype of the tensor.
Reported by Pylint.
Line: 71
Column: 1
"""
def __call__(self, shape, dtype=None, **kwargs):
"""Returns a tensor object initialized as specified by the initializer.
Args:
shape: Shape of the tensor.
dtype: Optional dtype of the tensor.
**kwargs: Additional keyword arguments.
Reported by Pylint.
Line: 78
Column: 1
dtype: Optional dtype of the tensor.
**kwargs: Additional keyword arguments.
"""
raise NotImplementedError('Initializer subclasses must implement the '
'`__call__()` method.')
def get_config(self):
"""Returns the configuration of the initializer as a JSON-serializable dict.
Reported by Pylint.
Line: 81
Column: 1
raise NotImplementedError('Initializer subclasses must implement the '
'`__call__()` method.')
def get_config(self):
"""Returns the configuration of the initializer as a JSON-serializable dict.
Returns:
A JSON-serializable Python dict.
"""
Reported by Pylint.
keras/saving/saving_utils_test.py
288 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests for saving utility functions."""
import tensorflow.compat.v2 as tf
import os
import numpy as np
Reported by Pylint.
Line: 39
Column: 9
def _assert_all_close(self, expected, actual):
if not tf.executing_eagerly():
with self.cached_session() as sess:
backend._initialize_variables(sess)
self.assertAllClose(expected, actual)
else:
self.assertAllClose(expected, actual)
@keras_parameterized.run_with_all_model_types
Reported by Pylint.
Line: 54
Column: 7
if input_dim is None:
with self.assertRaisesRegex(ValueError, 'input shapes have not been set'):
saving_utils.trace_model_call(model)
model._set_inputs(inputs)
fn = saving_utils.trace_model_call(model)
signature_outputs = fn(inputs)
if model.output_names:
expected_outputs = {model.output_names[0]: model(inputs)}
Reported by Pylint.
Line: 185
Column: 5
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
def test_subclassed_model_with_input_signature(self):
class Model(keras.Model):
def __init__(self):
super(Model, self).__init__()
self.dense = keras.layers.Dense(3, name='dense')
Reported by Pylint.
Line: 194
Column: 1
@tf.function(
input_signature=[[tf.TensorSpec([None, 5], tf.float32),
tf.TensorSpec([None], tf.float32)]],)
def call(self, inputs, *args):
x, y = inputs
return self.dense(x) + y
model = Model()
fn = saving_utils.trace_model_call(model)
Reported by Pylint.
Line: 263
Column: 26
def build(self, input_shape):
pass
def update_state(self, values):
if tf.constant(False):
x = 1
else:
x = 2
return x
Reported by Pylint.
Line: 263
Column: 3
def build(self, input_shape):
pass
def update_state(self, values):
if tf.constant(False):
x = 1
else:
x = 2
return x
Reported by Pylint.
Line: 286
Column: 5
class BasicAutographedMetricLayer(keras.layers.Layer):
def build(self, input_shape):
self._metric = AutographedMetric()
def call(self, inp):
self._metric.update_state(inp)
# TODO(b/172853147): Test control flow here.
return inp
Reported by Pylint.
Line: 288
Column: 3
def build(self, input_shape):
self._metric = AutographedMetric()
def call(self, inp):
self._metric.update_state(inp)
# TODO(b/172853147): Test control flow here.
return inp
Reported by Pylint.
Line: 290
Column: 3
def call(self, inp):
self._metric.update_state(inp)
# TODO(b/172853147): Test control flow here.
return inp
class BasicAutographedMetricModel(keras.models.Model):
Reported by Pylint.
keras/saving/saved_model/revive_test.py
288 issues
Line: 22
Column: 1
SavedModel have the expected structure.
"""
import tensorflow.compat.v2 as tf
# TODO(kathywu): Move relevant tests from saved_model_test to
import shutil
from absl.testing import parameterized
Reported by Pylint.
Line: 27
Column: 1
import shutil
from absl.testing import parameterized
import numpy as np
import keras
from keras import backend
from keras import keras_parameterized
Reported by Pylint.
Line: 30
Column: 1
from absl.testing import parameterized
import numpy as np
import keras
from keras import backend
from keras import keras_parameterized
from keras import testing_utils
from keras.saving.saved_model import load as keras_load
from keras.utils import generic_utils
Reported by Pylint.
Line: 31
Column: 1
import numpy as np
import keras
from keras import backend
from keras import keras_parameterized
from keras import testing_utils
from keras.saving.saved_model import load as keras_load
from keras.utils import generic_utils
Reported by Pylint.
Line: 32
Column: 1
import keras
from keras import backend
from keras import keras_parameterized
from keras import testing_utils
from keras.saving.saved_model import load as keras_load
from keras.utils import generic_utils
Reported by Pylint.
Line: 33
Column: 1
import keras
from keras import backend
from keras import keras_parameterized
from keras import testing_utils
from keras.saving.saved_model import load as keras_load
from keras.utils import generic_utils
class SubclassedModelNoConfig(keras.Model):
Reported by Pylint.
Line: 34
Column: 1
from keras import backend
from keras import keras_parameterized
from keras import testing_utils
from keras.saving.saved_model import load as keras_load
from keras.utils import generic_utils
class SubclassedModelNoConfig(keras.Model):
Reported by Pylint.
Line: 35
Column: 1
from keras import keras_parameterized
from keras import testing_utils
from keras.saving.saved_model import load as keras_load
from keras.utils import generic_utils
class SubclassedModelNoConfig(keras.Model):
def __init__(self, a, b):
Reported by Pylint.
Line: 23
Column: 3
"""
import tensorflow.compat.v2 as tf
# TODO(kathywu): Move relevant tests from saved_model_test to
import shutil
from absl.testing import parameterized
import numpy as np
Reported by Pylint.
Line: 54
Column: 3
CustomLayerWithConfig(self.a + 1, self.b + 2),
CustomLayerNoConfig(self.a + 3, self.b + 4),
keras.Sequential([
# TODO(b/145029112): Bug with losses when there are shared layers.
# self.shared, <-- Enable when bug is fixed.
CustomLayerNoConfig(self.a + 5, self.b + 6)])])
super(SubclassedModelNoConfig, self).build(input_shape)
def call(self, inputs):
Reported by Pylint.
keras/models.py
277 issues
Line: 18
Column: 1
# pylint: disable=protected-access
"""Code for model cloning, plus model-related API entries."""
import tensorflow.compat.v2 as tf
from keras import backend
from keras import metrics as metrics_module
from keras import optimizer_v1
from keras.engine import functional
from keras.engine import sequential
Reported by Pylint.
Line: 35
Column: 1
from keras.utils import generic_utils
from keras.utils import version_utils
from keras.utils.generic_utils import CustomObjectScope
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export
# API entries importable from `keras.models`:
Model = training.Model # pylint: disable=invalid-name
Reported by Pylint.
Line: 36
Column: 1
from keras.utils import version_utils
from keras.utils.generic_utils import CustomObjectScope
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export
# API entries importable from `keras.models`:
Model = training.Model # pylint: disable=invalid-name
Sequential = sequential.Sequential # pylint: disable=invalid-name
Reported by Pylint.
Line: 206
Column: 3
ancillary_layers = [
layer for layer in created_layers.values() if layer not in model.layers
]
# TODO(b/162887610): This may need to adjust the inbound node index if the
# created layers had already been used to define other models.
if ancillary_layers:
new_nodes = tf.nest.flatten([
layer.inbound_nodes[1:]
if functional._should_skip_first_node(layer)
Reported by Pylint.
Line: 700
Column: 11
'`get_config` and `from_config` to better support '
'cloning the model.')
if not in_place_reset:
raise ValueError(
f'This model ({model}) is a subclassed model. '
'Such a model cannot be cloned, but there is a workaround where '
'the model is reset in-place. To use this, please set the '
'argument `in_place_reset` to `True`. This will reset the '
'attributes in the original model. To restore the attributes, '
Reported by Pylint.
Line: 35
Column: 1
from keras.utils import generic_utils
from keras.utils import version_utils
from keras.utils.generic_utils import CustomObjectScope
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export
# API entries importable from `keras.models`:
Model = training.Model # pylint: disable=invalid-name
Reported by Pylint.
Line: 36
Column: 1
from keras.utils import version_utils
from keras.utils.generic_utils import CustomObjectScope
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export
# API entries importable from `keras.models`:
Model = training.Model # pylint: disable=invalid-name
Sequential = sequential.Sequential # pylint: disable=invalid-name
Reported by Pylint.
Line: 51
Column: 1
# Callable used to clone a layer with weights preserved.
def share_weights(layer):
return layer
def _clone_layer(layer):
return layer.__class__.from_config(layer.get_config())
Reported by Pylint.
Line: 52
Column: 1
# Callable used to clone a layer with weights preserved.
def share_weights(layer):
return layer
def _clone_layer(layer):
return layer.__class__.from_config(layer.get_config())
Reported by Pylint.
Line: 56
Column: 1
def _clone_layer(layer):
return layer.__class__.from_config(layer.get_config())
def _insert_ancillary_layers(model, ancillary_layers, metrics_names, new_nodes):
"""Inserts ancillary layers into the model with the proper order."""
# Sort `AddMetric` layers so they agree with metrics_names.
Reported by Pylint.
keras/engine/training_generator_test.py
276 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests for training routines."""
import tensorflow.compat.v2 as tf
import itertools
from absl.testing import parameterized
import numpy as np
Reported by Pylint.
Line: 21
Column: 1
import itertools
from absl.testing import parameterized
import numpy as np
from keras import combinations
from keras import keras_parameterized
from keras import layers as layers_module
from keras import losses
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
import itertools
from absl.testing import parameterized
import numpy as np
from keras import combinations
from keras import keras_parameterized
Reported by Pylint.
Line: 36
Column: 1
from keras.utils import data_utils
def custom_generator(mode=2):
batch_size = 10
num_samples = 50
arr_data = np.random.random((num_samples, 2))
arr_labels = np.random.random((num_samples, 4))
arr_weights = np.random.random((num_samples,))
Reported by Pylint.
Line: 37
Column: 1
def custom_generator(mode=2):
batch_size = 10
num_samples = 50
arr_data = np.random.random((num_samples, 2))
arr_labels = np.random.random((num_samples, 4))
arr_weights = np.random.random((num_samples,))
i = 0
Reported by Pylint.
Line: 38
Column: 1
def custom_generator(mode=2):
batch_size = 10
num_samples = 50
arr_data = np.random.random((num_samples, 2))
arr_labels = np.random.random((num_samples, 4))
arr_weights = np.random.random((num_samples,))
i = 0
while True:
Reported by Pylint.
Line: 39
Column: 1
def custom_generator(mode=2):
batch_size = 10
num_samples = 50
arr_data = np.random.random((num_samples, 2))
arr_labels = np.random.random((num_samples, 4))
arr_weights = np.random.random((num_samples,))
i = 0
while True:
batch_index = i * batch_size % num_samples
Reported by Pylint.
Line: 40
Column: 1
batch_size = 10
num_samples = 50
arr_data = np.random.random((num_samples, 2))
arr_labels = np.random.random((num_samples, 4))
arr_weights = np.random.random((num_samples,))
i = 0
while True:
batch_index = i * batch_size % num_samples
i += 1
Reported by Pylint.
Line: 41
Column: 1
num_samples = 50
arr_data = np.random.random((num_samples, 2))
arr_labels = np.random.random((num_samples, 4))
arr_weights = np.random.random((num_samples,))
i = 0
while True:
batch_index = i * batch_size % num_samples
i += 1
start = batch_index
Reported by Pylint.
Line: 42
Column: 1
arr_data = np.random.random((num_samples, 2))
arr_labels = np.random.random((num_samples, 4))
arr_weights = np.random.random((num_samples,))
i = 0
while True:
batch_index = i * batch_size % num_samples
i += 1
start = batch_index
end = start + batch_size
Reported by Pylint.
keras/engine/keras_tensor.py
275 issues
Line: 17
Column: 1
# ==============================================================================
"""Keras Input Tensor used to track functional API Topology."""
import tensorflow.compat.v2 as tf
from keras.utils import object_identity
# pylint: disable=g-classes-have-attributes
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
from keras.utils import object_identity
# pylint: disable=g-classes-have-attributes
# Tensorflow tensors have a maximum rank of 254
# (See `MaxDimensions()` in //tensorflow/core/framework/tensor_shape.h )
# So we do not try to infer values for int32 tensors larger than this,
Reported by Pylint.
Line: 281
Column: 15
name_string = ''
if hasattr(self, '_keras_history'):
layer = self._keras_history.layer
symbolic_description = (
', description="created by layer \'%s\'"' % (layer.name,))
if self._inferred_value is not None:
inferred_value_string = (
', inferred_value=%s' % self._inferred_value)
Reported by Pylint.
Line: 302
Column: 15
type_spec_string = 'type_spec=%s' % self.type_spec
if hasattr(self, '_keras_history'):
layer = self._keras_history.layer
symbolic_description = ' (created by layer \'%s\')' % (layer.name,)
if self._inferred_value is not None:
inferred_value_string = (
' inferred_value=%s' % self._inferred_value)
return '<KerasTensor: %s%s%s>' % (
Reported by Pylint.
Line: 340
Column: 30
None if there isn't any KerasHistory attached to this tensor.
"""
if hasattr(self, '_keras_history'):
layer, node_index, _ = self._keras_history
return layer.inbound_nodes[node_index]
return None
def __iter__(self):
shape = None
Reported by Pylint.
Line: 127
Column: 3
@property
def shape(self):
"""Returns the `TensorShape` symbolically inferred for this Keras output."""
# TODO(kaftan): This is only valid for normal/sparse/ragged tensors.
# may need to raise an error when it's not valid for a type_spec,
# but some keras code (e.g. build-related stuff) will likely fail when
# it can't access shape or dtype
return self._type_spec._shape # pylint: disable=protected-access
Reported by Pylint.
Line: 313
Column: 3
@property
def dtype(self):
"""Returns the `dtype` symbolically inferred for this Keras output."""
# TODO(kaftan): This is only valid for normal/sparse/ragged tensors.
# may need to raise an error when it's not valid for a type_spec,
# but some keras code (e.g. build-related stuff) will likely fail when
# it can't access shape or dtype
return self._type_spec._dtype # pylint: disable=protected-access
Reported by Pylint.
Line: 477
Column: 3
RaggedKerasTensor._overload_operator(tf.RaggedTensor, '__rmul__') # pylint: disable=protected-access
# TODO(b/161487382):
# Special-case user-registered symbolic objects (registered by the
# private `register_symbolic_tensor_type` method) by passing them between
# scratch graphs directly.
# This is needed to not break Tensorflow probability
# while they finish migrating to composite tensors.
Reported by Pylint.
Line: 507
Column: 3
raise NotImplementedError
# TODO(b/161487382):
# Special-case user-registered symbolic objects (registered by the
# private `register_symbolic_tensor_type` method) by passing them between
# scratch graphs directly.
# This is needed to not break Tensorflow probability
# while they finish migrating to composite tensors.
Reported by Pylint.
Line: 599
Column: 5
out = keras_tensor_cls.from_tensor(tensor)
if hasattr(tensor, '_keras_mask'):
out._keras_mask = keras_tensor_from_tensor(tensor._keras_mask) # pylint: disable=protected-access
return out
def keras_tensor_from_type_spec(type_spec, name=None):
"""Convert a TypeSpec to a representative KerasTensor."""
Reported by Pylint.
keras/distribute/keras_correctness_test_base.py
274 issues
Line: 17
Column: 1
# ==============================================================================
"""Correctness tests for tf.keras using DistributionStrategy."""
import tensorflow.compat.v2 as tf
import functools
from absl.testing import parameterized
import numpy as np
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
import functools
from absl.testing import parameterized
import numpy as np
import keras
from keras.distribute import distributed_training_utils
from keras.distribute.strategy_combinations import all_strategies
Reported by Pylint.
Line: 81
Column: 3
def test_combinations_for_embedding_model():
# TODO(sourabhbajaj): Enable tests for eager mode
eager_mode_strategies = [
s for s in strategies_for_embedding_models() if not s.required_tpu
]
return (tf.__internal__.test.combinations.times(
Reported by Pylint.
Line: 143
Column: 3
def get_batch_size(global_batch_size, distribution):
batch_size = global_batch_size
# TODO(b/118776054): Use global batch size for Keras/DS support.
use_per_core_batch_size = (
distribution and
not distributed_training_utils.global_batch_size_supported(distribution))
if use_per_core_batch_size:
batch_size //= distribution.num_replicas_in_sync
Reported by Pylint.
Line: 326
Column: 3
isinstance(distribution,
(tf.distribute.experimental.TPUStrategy, tf.compat.v1.distribute.experimental.TPUStrategy)) and
distribution.extended.steps_per_run > 1):
# TODO(b/119894254): Enable this test for all cases once the
# underlying bug is fixed.
continue
tolerance = _get_compare_result_tolerance(key)
Reported by Pylint.
Line: 360
Column: 3
class LearningRateBatchScheduler(keras.callbacks.Callback):
"""Scheduler that dynamically sets the learning rate of model."""
def __init__(self, update_freq=None):
self._update_freq = update_freq
def on_batch_begin(self, batch, logs=None):
if self._update_freq and batch % self._update_freq != 0:
return
Reported by Pylint.
Line: 380
Column: 5
use_numpy=False,
use_validation_data=False,
with_batch_norm=None):
self.use_numpy = use_numpy
self.use_validation_data = use_validation_data
self.with_batch_norm = with_batch_norm
keras.backend.set_image_data_format('channels_last')
np.random.seed(_RANDOM_SEED)
Reported by Pylint.
Line: 381
Column: 5
use_validation_data=False,
with_batch_norm=None):
self.use_numpy = use_numpy
self.use_validation_data = use_validation_data
self.with_batch_norm = with_batch_norm
keras.backend.set_image_data_format('channels_last')
np.random.seed(_RANDOM_SEED)
tf.compat.v1.set_random_seed(_RANDOM_SEED)
Reported by Pylint.
Line: 382
Column: 5
with_batch_norm=None):
self.use_numpy = use_numpy
self.use_validation_data = use_validation_data
self.with_batch_norm = with_batch_norm
keras.backend.set_image_data_format('channels_last')
np.random.seed(_RANDOM_SEED)
tf.compat.v1.set_random_seed(_RANDOM_SEED)
Reported by Pylint.
Line: 583
Column: 1
results_with_ds, results_without_ds, distribution, testcase=self)
class TestDistributionStrategyEmbeddingModelCorrectnessBase(
TestDistributionStrategyCorrectnessBase):
"""Base class to test correctness of Keras models with embedding layers."""
def get_data(self,
count=(_GLOBAL_BATCH_SIZE * _EVAL_STEPS),
Reported by Pylint.
keras/engine/sequential.py
270 issues
Line: 18
Column: 1
# pylint: disable=protected-access
"""Home of the `Sequential` model."""
import tensorflow.compat.v2 as tf
import copy
from keras import layers as layer_module
from keras.engine import base_layer
from keras.engine import functional
Reported by Pylint.
Line: 32
Column: 1
from keras.utils import tf_inspect
from keras.utils import tf_utils
from keras.utils import traceback_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export
SINGLE_LAYER_OUTPUT_ERROR_MSG = ('All layers in a Sequential model should have '
'a single output tensor. For multi-output '
Reported by Pylint.
Line: 33
Column: 1
from keras.utils import tf_utils
from keras.utils import traceback_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export
SINGLE_LAYER_OUTPUT_ERROR_MSG = ('All layers in a Sequential model should have '
'a single output tensor. For multi-output '
'layers, use the functional API.')
Reported by Pylint.
Line: 330
Column: 3
# However some users have layers that are fundamentally incompatible
# with the Functional API, which do not return tensors. In this
# case, we fall back to the legacy deferred behavior.
# TODO(fchollet): consider raising here, as we should not be
# supporting such layers.
self._init_graph_network(inputs, outputs)
self._graph_initialized = True
except: # pylint:disable=bare-except
self._use_legacy_deferred_behavior = True
Reported by Pylint.
Line: 403
Column: 3
return shape
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.
outputs = self.call(inputs, mask=mask) # pylint: disable=unexpected-keyword-arg
return getattr(outputs, '_keras_mask', None)
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
import copy
from keras import layers as layer_module
from keras.engine import base_layer
from keras.engine import functional
from keras.engine import input_layer
from keras.engine import training_utils
Reported by Pylint.
Line: 42
Column: 1
@keras_export('keras.Sequential', 'keras.models.Sequential')
class Sequential(functional.Functional):
"""`Sequential` groups a linear stack of layers into a `tf.keras.Model`.
`Sequential` provides training and inference features on this model.
Examples:
Reported by Pylint.
Line: 43
Column: 1
@keras_export('keras.Sequential', 'keras.models.Sequential')
class Sequential(functional.Functional):
"""`Sequential` groups a linear stack of layers into a `tf.keras.Model`.
`Sequential` provides training and inference features on this model.
Examples:
Reported by Pylint.
Line: 99
Column: 1
```
"""
@tf.__internal__.tracking.no_automatic_dependency_tracking
@traceback_utils.filter_traceback
def __init__(self, layers=None, name=None):
"""Creates a `Sequential` model instance.
Args:
Reported by Pylint.
Line: 100
Column: 1
"""
@tf.__internal__.tracking.no_automatic_dependency_tracking
@traceback_utils.filter_traceback
def __init__(self, layers=None, name=None):
"""Creates a `Sequential` model instance.
Args:
layers: Optional list of layers to add to the model.
Reported by Pylint.
keras/integration_test/legacy_rnn_test.py
270 issues
Line: 17
Column: 1
# ==============================================================================
import numpy as np
import tensorflow.compat.v1 as tf
tf.disable_eager_execution()
class KerasNetworkTFRNNs(tf.keras.Model):
Reported by Pylint.
Line: 1
Column: 1
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
Reported by Pylint.
Line: 22
Column: 1
tf.disable_eager_execution()
class KerasNetworkTFRNNs(tf.keras.Model):
def __init__(self, name=None):
super(KerasNetworkTFRNNs, self).__init__(name=name)
self._cell = tf.nn.rnn_cell.MultiRNNCell(
[tf.nn.rnn_cell.LSTMCell(1) for _ in range(2)])
Reported by Pylint.
Line: 22
Column: 1
tf.disable_eager_execution()
class KerasNetworkTFRNNs(tf.keras.Model):
def __init__(self, name=None):
super(KerasNetworkTFRNNs, self).__init__(name=name)
self._cell = tf.nn.rnn_cell.MultiRNNCell(
[tf.nn.rnn_cell.LSTMCell(1) for _ in range(2)])
Reported by Pylint.
Line: 24
Column: 1
class KerasNetworkTFRNNs(tf.keras.Model):
def __init__(self, name=None):
super(KerasNetworkTFRNNs, self).__init__(name=name)
self._cell = tf.nn.rnn_cell.MultiRNNCell(
[tf.nn.rnn_cell.LSTMCell(1) for _ in range(2)])
def call(self, inputs):
Reported by Pylint.
Line: 25
Column: 5
class KerasNetworkTFRNNs(tf.keras.Model):
def __init__(self, name=None):
super(KerasNetworkTFRNNs, self).__init__(name=name)
self._cell = tf.nn.rnn_cell.MultiRNNCell(
[tf.nn.rnn_cell.LSTMCell(1) for _ in range(2)])
def call(self, inputs):
return self._cell(inputs, self._cell.get_initial_state(inputs))
Reported by Pylint.
Line: 25
Column: 1
class KerasNetworkTFRNNs(tf.keras.Model):
def __init__(self, name=None):
super(KerasNetworkTFRNNs, self).__init__(name=name)
self._cell = tf.nn.rnn_cell.MultiRNNCell(
[tf.nn.rnn_cell.LSTMCell(1) for _ in range(2)])
def call(self, inputs):
return self._cell(inputs, self._cell.get_initial_state(inputs))
Reported by Pylint.
Line: 26
Column: 1
def __init__(self, name=None):
super(KerasNetworkTFRNNs, self).__init__(name=name)
self._cell = tf.nn.rnn_cell.MultiRNNCell(
[tf.nn.rnn_cell.LSTMCell(1) for _ in range(2)])
def call(self, inputs):
return self._cell(inputs, self._cell.get_initial_state(inputs))
Reported by Pylint.
Line: 29
Column: 3
self._cell = tf.nn.rnn_cell.MultiRNNCell(
[tf.nn.rnn_cell.LSTMCell(1) for _ in range(2)])
def call(self, inputs):
return self._cell(inputs, self._cell.get_initial_state(inputs))
class KerasNetworkKerasRNNs(tf.keras.Model):
Reported by Pylint.
Line: 29
Column: 1
self._cell = tf.nn.rnn_cell.MultiRNNCell(
[tf.nn.rnn_cell.LSTMCell(1) for _ in range(2)])
def call(self, inputs):
return self._cell(inputs, self._cell.get_initial_state(inputs))
class KerasNetworkKerasRNNs(tf.keras.Model):
Reported by Pylint.