The following issues were found
keras/feature_column/sequence_feature_column_test.py
238 issues
Line: 21
Column: 1
from __future__ import division
from __future__ import print_function
import tensorflow.compat.v2 as tf
from absl.testing import parameterized
import numpy as np
Reported by Pylint.
Line: 24
Column: 1
import tensorflow.compat.v2 as tf
from absl.testing import parameterized
import numpy as np
import keras
from keras import combinations
from keras.feature_column import sequence_feature_column as ksfc
Reported by Pylint.
Line: 591
Column: 20
self.assertEqual(new_layer.name, orig_layer.name)
self.assertEqual(new_layer.trainable, trainable)
self.assertLen(new_layer._feature_columns, 1)
self.assertEqual(new_layer._feature_columns[0].name, 'a')
def test_serialization_sequence_features(self):
rating = tf.feature_column.sequence_numeric_column('rating')
sequence_feature = ksfc.SequenceFeatures([rating])
Reported by Pylint.
Line: 592
Column: 22
self.assertEqual(new_layer.name, orig_layer.name)
self.assertEqual(new_layer.trainable, trainable)
self.assertLen(new_layer._feature_columns, 1)
self.assertEqual(new_layer._feature_columns[0].name, 'a')
def test_serialization_sequence_features(self):
rating = tf.feature_column.sequence_numeric_column('rating')
sequence_feature = ksfc.SequenceFeatures([rating])
config = keras.layers.serialize(sequence_feature)
Reported by Pylint.
Line: 622
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.
Line: 34
Column: 1
def _initialized_session(config=None):
sess = tf.compat.v1.Session(config=config)
sess.run(tf.compat.v1.global_variables_initializer())
sess.run(tf.compat.v1.tables_initializer())
return sess
Reported by Pylint.
Line: 35
Column: 1
def _initialized_session(config=None):
sess = tf.compat.v1.Session(config=config)
sess.run(tf.compat.v1.global_variables_initializer())
sess.run(tf.compat.v1.tables_initializer())
return sess
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
Reported by Pylint.
Line: 36
Column: 1
def _initialized_session(config=None):
sess = tf.compat.v1.Session(config=config)
sess.run(tf.compat.v1.global_variables_initializer())
sess.run(tf.compat.v1.tables_initializer())
return sess
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
class SequenceFeaturesTest(tf.test.TestCase, parameterized.TestCase):
Reported by Pylint.
Line: 37
Column: 1
sess = tf.compat.v1.Session(config=config)
sess.run(tf.compat.v1.global_variables_initializer())
sess.run(tf.compat.v1.tables_initializer())
return sess
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
class SequenceFeaturesTest(tf.test.TestCase, parameterized.TestCase):
Reported by Pylint.
Line: 41
Column: 1
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
class SequenceFeaturesTest(tf.test.TestCase, parameterized.TestCase):
@parameterized.named_parameters(
{'testcase_name': '2D',
'sparse_input_args_a': {
# example 0, ids [2]
Reported by Pylint.
keras/preprocessing/image_dataset_test.py
237 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests for image_dataset."""
import tensorflow.compat.v2 as tf
import os
import shutil
import numpy as np
Reported by Pylint.
Line: 28
Column: 1
from keras.preprocessing import image_dataset
try:
import PIL # pylint:disable=g-import-not-at-top
except ImportError:
PIL = None
class ImageDatasetFromDirectoryTest(keras_parameterized.TestCase):
Reported by Pylint.
Line: 51
Column: 26
def _prepare_directory(self,
num_classes=2,
grayscale=False,
nested_dirs=False,
color_mode='rgb',
count=16):
# Get a unique temp directory
temp_dir = os.path.join(self.get_temp_dir(), str(np.random.randint(1e6)))
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
import os
import shutil
import numpy as np
from keras import keras_parameterized
from keras.preprocessing import image as image_preproc
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
import os
import shutil
import numpy as np
from keras import keras_parameterized
from keras.preprocessing import image as image_preproc
from keras.preprocessing import image_dataset
Reported by Pylint.
Line: 28
Column: 1
from keras.preprocessing import image_dataset
try:
import PIL # pylint:disable=g-import-not-at-top
except ImportError:
PIL = None
class ImageDatasetFromDirectoryTest(keras_parameterized.TestCase):
Reported by Pylint.
Line: 30
Column: 1
try:
import PIL # pylint:disable=g-import-not-at-top
except ImportError:
PIL = None
class ImageDatasetFromDirectoryTest(keras_parameterized.TestCase):
def _get_images(self, count=16, color_mode='rgb'):
Reported by Pylint.
Line: 33
Column: 1
PIL = None
class ImageDatasetFromDirectoryTest(keras_parameterized.TestCase):
def _get_images(self, count=16, color_mode='rgb'):
width = height = 24
imgs = []
for _ in range(count):
Reported by Pylint.
Line: 35
Column: 3
class ImageDatasetFromDirectoryTest(keras_parameterized.TestCase):
def _get_images(self, count=16, color_mode='rgb'):
width = height = 24
imgs = []
for _ in range(count):
if color_mode == 'grayscale':
img = np.random.randint(0, 256, size=(height, width, 1))
Reported by Pylint.
Line: 35
Column: 1
class ImageDatasetFromDirectoryTest(keras_parameterized.TestCase):
def _get_images(self, count=16, color_mode='rgb'):
width = height = 24
imgs = []
for _ in range(count):
if color_mode == 'grayscale':
img = np.random.randint(0, 256, size=(height, width, 1))
Reported by Pylint.
keras/engine/ragged_keras_tensor_test.py
236 issues
Line: 17
Column: 1
# ==============================================================================
"""RaggedKerasTensor tests."""
import tensorflow.compat.v2 as tf
from absl.testing import parameterized
import numpy as np
from keras import keras_parameterized
from keras import layers
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
from absl.testing import parameterized
import numpy as np
from keras import keras_parameterized
from keras import layers
from keras.engine import training
Reported by Pylint.
Line: 47
Column: 21
self.assertEqual(inp.ragged_rank, ragged_rank)
self.assertAllEqual(inp.shape, [batch_size] + list(shape))
with tf.__internal__.FuncGraph('test').as_default():
placeholder = inp._to_placeholder()
self.assertEqual(placeholder.ragged_rank, ragged_rank)
self.assertAllEqual(placeholder.shape, [batch_size] + list(shape))
def test_add(self):
inp = layers.Input(shape=[None], ragged=True)
Reported by Pylint.
Line: 26
Column: 1
from keras.engine import training
class RaggedKerasTensorTest(keras_parameterized.TestCase):
@parameterized.parameters(
{'batch_size': None, 'shape': (None, 5), 'ragged_rank': 1},
{'batch_size': None, 'shape': (None, 3, 5), 'ragged_rank': 1},
{'batch_size': None, 'shape': (5, None), 'ragged_rank': 2},
Reported by Pylint.
Line: 28
Column: 1
class RaggedKerasTensorTest(keras_parameterized.TestCase):
@parameterized.parameters(
{'batch_size': None, 'shape': (None, 5), 'ragged_rank': 1},
{'batch_size': None, 'shape': (None, 3, 5), 'ragged_rank': 1},
{'batch_size': None, 'shape': (5, None), 'ragged_rank': 2},
{'batch_size': None, 'shape': (3, 5, None), 'ragged_rank': 3},
{'batch_size': None, 'shape': (None, 3, 5, None), 'ragged_rank': 4},
Reported by Pylint.
Line: 41
Column: 3
{'batch_size': 4, 'shape': (3, 5, None), 'ragged_rank': 3},
{'batch_size': 7, 'shape': (None, 3, 5, None), 'ragged_rank': 4},
{'batch_size': 12, 'shape': (2, 3, None, 4, 5, None), 'ragged_rank': 6},
)
def test_to_placeholder(self, shape, batch_size, ragged_rank):
inp = layers.Input(shape=shape, batch_size=batch_size, ragged=True)
self.assertEqual(inp.ragged_rank, ragged_rank)
self.assertAllEqual(inp.shape, [batch_size] + list(shape))
with tf.__internal__.FuncGraph('test').as_default():
Reported by Pylint.
Line: 42
Column: 1
{'batch_size': 7, 'shape': (None, 3, 5, None), 'ragged_rank': 4},
{'batch_size': 12, 'shape': (2, 3, None, 4, 5, None), 'ragged_rank': 6},
)
def test_to_placeholder(self, shape, batch_size, ragged_rank):
inp = layers.Input(shape=shape, batch_size=batch_size, ragged=True)
self.assertEqual(inp.ragged_rank, ragged_rank)
self.assertAllEqual(inp.shape, [batch_size] + list(shape))
with tf.__internal__.FuncGraph('test').as_default():
placeholder = inp._to_placeholder()
Reported by Pylint.
Line: 43
Column: 1
{'batch_size': 12, 'shape': (2, 3, None, 4, 5, None), 'ragged_rank': 6},
)
def test_to_placeholder(self, shape, batch_size, ragged_rank):
inp = layers.Input(shape=shape, batch_size=batch_size, ragged=True)
self.assertEqual(inp.ragged_rank, ragged_rank)
self.assertAllEqual(inp.shape, [batch_size] + list(shape))
with tf.__internal__.FuncGraph('test').as_default():
placeholder = inp._to_placeholder()
self.assertEqual(placeholder.ragged_rank, ragged_rank)
Reported by Pylint.
Line: 44
Column: 1
)
def test_to_placeholder(self, shape, batch_size, ragged_rank):
inp = layers.Input(shape=shape, batch_size=batch_size, ragged=True)
self.assertEqual(inp.ragged_rank, ragged_rank)
self.assertAllEqual(inp.shape, [batch_size] + list(shape))
with tf.__internal__.FuncGraph('test').as_default():
placeholder = inp._to_placeholder()
self.assertEqual(placeholder.ragged_rank, ragged_rank)
self.assertAllEqual(placeholder.shape, [batch_size] + list(shape))
Reported by Pylint.
Line: 45
Column: 1
def test_to_placeholder(self, shape, batch_size, ragged_rank):
inp = layers.Input(shape=shape, batch_size=batch_size, ragged=True)
self.assertEqual(inp.ragged_rank, ragged_rank)
self.assertAllEqual(inp.shape, [batch_size] + list(shape))
with tf.__internal__.FuncGraph('test').as_default():
placeholder = inp._to_placeholder()
self.assertEqual(placeholder.ragged_rank, ragged_rank)
self.assertAllEqual(placeholder.shape, [batch_size] + list(shape))
Reported by Pylint.
keras/utils/layer_utils.py
235 issues
Line: 18
Column: 1
# pylint: disable=protected-access
"""Utilities related to layer/model functionality."""
import tensorflow.compat.v2 as tf
import functools
import weakref
import numpy as np
Reported by Pylint.
Line: 24
Column: 1
import weakref
import numpy as np
from tensorflow.python.util.tf_export import keras_export
@keras_export('keras.utils.get_source_inputs')
def get_source_inputs(tensor, layer=None, node_index=None):
"""Returns the list of input tensors necessary to compute `tensor`.
Reported by Pylint.
Line: 438
Column: 3
def filter_empty_layer_containers(layer_list):
"""Filter out empty Layer-like containers and uniquify."""
# TODO(b/130381733): Make this an attribute in base_layer.Layer.
existing = set()
to_visit = layer_list[::-1]
while to_visit:
obj = to_visit.pop()
if id(obj) in existing:
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
import functools
import weakref
import numpy as np
from tensorflow.python.util.tf_export import keras_export
Reported by Pylint.
Line: 21
Column: 1
import tensorflow.compat.v2 as tf
import functools
import weakref
import numpy as np
from tensorflow.python.util.tf_export import keras_export
Reported by Pylint.
Line: 29
Column: 1
@keras_export('keras.utils.get_source_inputs')
def get_source_inputs(tensor, layer=None, node_index=None):
"""Returns the list of input tensors necessary to compute `tensor`.
Output will always be a list of tensors
(potentially with 1 element).
Args:
Reported by Pylint.
Line: 43
Column: 1
Returns:
List of input tensors.
"""
if not hasattr(tensor, '_keras_history'):
return tensor
if layer is None or node_index:
layer, node_index, _ = tensor._keras_history
if not layer._inbound_nodes:
Reported by Pylint.
Line: 44
Column: 1
List of input tensors.
"""
if not hasattr(tensor, '_keras_history'):
return tensor
if layer is None or node_index:
layer, node_index, _ = tensor._keras_history
if not layer._inbound_nodes:
return [tensor]
Reported by Pylint.
Line: 46
Column: 1
if not hasattr(tensor, '_keras_history'):
return tensor
if layer is None or node_index:
layer, node_index, _ = tensor._keras_history
if not layer._inbound_nodes:
return [tensor]
else:
node = layer._inbound_nodes[node_index]
Reported by Pylint.
Line: 47
Column: 1
return tensor
if layer is None or node_index:
layer, node_index, _ = tensor._keras_history
if not layer._inbound_nodes:
return [tensor]
else:
node = layer._inbound_nodes[node_index]
if node.is_input:
Reported by Pylint.
keras/utils/tf_utils.py
230 issues
Line: 17
Column: 1
# ==============================================================================
"""TensorFlow-related utilities."""
import tensorflow.compat.v2 as tf
import collections
import copy
import numpy as np
from tensorflow.python.framework import ops
Reported by Pylint.
Line: 22
Column: 1
import collections
import copy
import numpy as np
from tensorflow.python.framework import ops
from keras import backend as K
from keras.engine import keras_tensor
from keras.utils import object_identity
from keras.utils import tf_contextlib
from tensorflow.python.util.tf_export import keras_export
Reported by Pylint.
Line: 27
Column: 1
from keras.engine import keras_tensor
from keras.utils import object_identity
from keras.utils import tf_contextlib
from tensorflow.python.util.tf_export import keras_export
def is_tensor_or_tensor_list(v):
v = tf.nest.flatten(v)
if v and isinstance(v[0], tf.Tensor):
Reported by Pylint.
Line: 313
Column: 3
elif isinstance(tensor, tf.Variable):
# Variables that are output of a Keras Layer in Functional API mode
# should be considered symbolic.
# TODO(omalleyt): We need a better way to check this in order to
# enable `run_eagerly=True` for Models containing Layers that
# return Variables as outputs.
return (getattr(tensor, '_keras_history', False) or
not tf.executing_eagerly())
elif isinstance(tensor, tuple(_user_convertible_tensor_types)):
Reported by Pylint.
Line: 355
Column: 3
Args:
cls: A `class` type which shall be regarded as a symbolic `Tensor`.
"""
global _user_convertible_tensor_types
if cls not in _user_convertible_tensor_types:
keras_tensor.register_keras_tensor_specialization(
cls, keras_tensor.UserRegisteredTypeKerasTensor)
_user_convertible_tensor_types.add(cls)
Reported by Pylint.
Line: 463
Column: 3
if isinstance(t, tf.TypeSpec):
spec = t
elif is_extension_type(t):
# TODO(b/148821952): Should these specs have a name attr?
spec = t._type_spec
elif (hasattr(t, '_keras_history') and
hasattr(t._keras_history[0], '_type_spec')):
return t._keras_history[0]._type_spec
elif hasattr(t, 'shape') and hasattr(t, 'dtype'):
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
import collections
import copy
import numpy as np
from tensorflow.python.framework import ops
from keras import backend as K
from keras.engine import keras_tensor
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
import collections
import copy
import numpy as np
from tensorflow.python.framework import ops
from keras import backend as K
from keras.engine import keras_tensor
from keras.utils import object_identity
Reported by Pylint.
Line: 27
Column: 1
from keras.engine import keras_tensor
from keras.utils import object_identity
from keras.utils import tf_contextlib
from tensorflow.python.util.tf_export import keras_export
def is_tensor_or_tensor_list(v):
v = tf.nest.flatten(v)
if v and isinstance(v[0], tf.Tensor):
Reported by Pylint.
Line: 30
Column: 1
from tensorflow.python.util.tf_export import keras_export
def is_tensor_or_tensor_list(v):
v = tf.nest.flatten(v)
if v and isinstance(v[0], tf.Tensor):
return True
else:
return False
Reported by Pylint.
keras/layers/core/tf_op_layer.py
227 issues
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
"""Contains the TFOpLambda layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import,g-bad-import-order
import tensorflow.compat.v2 as tf
# pylint: enable=g-bad-import-order
from keras import backend as K
from keras.engine import keras_tensor
Reported by Pylint.
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
"""Contains the TFOpLambda layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import,g-bad-import-order
import tensorflow.compat.v2 as tf
# pylint: enable=g-bad-import-order
from keras import backend as K
from keras.engine import keras_tensor
Reported by Pylint.
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
"""Contains the TFOpLambda layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import,g-bad-import-order
import tensorflow.compat.v2 as tf
# pylint: enable=g-bad-import-order
from keras import backend as K
from keras.engine import keras_tensor
Reported by Pylint.
Line: 17
Column: 1
# ==============================================================================
"""Contains the TFOpLambda layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import,g-bad-import-order
import tensorflow.compat.v2 as tf
# pylint: enable=g-bad-import-order
from keras import backend as K
from keras.engine import keras_tensor
from keras.engine.base_layer import Layer
Reported by Pylint.
Line: 18
Column: 1
"""Contains the TFOpLambda layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import,g-bad-import-order
import tensorflow.compat.v2 as tf
# pylint: enable=g-bad-import-order
from keras import backend as K
from keras.engine import keras_tensor
from keras.engine.base_layer import Layer
Reported by Pylint.
Line: 24
Column: 1
from keras.engine import keras_tensor
from keras.engine.base_layer import Layer
from tensorflow.python.platform import tf_logging
from tensorflow.python.util.tf_export import get_canonical_name_for_symbol
from tensorflow.python.util.tf_export import get_symbol_from_name
class ClassMethod(Layer):
Reported by Pylint.
Line: 25
Column: 1
from keras.engine.base_layer import Layer
from tensorflow.python.platform import tf_logging
from tensorflow.python.util.tf_export import get_canonical_name_for_symbol
from tensorflow.python.util.tf_export import get_symbol_from_name
class ClassMethod(Layer):
"""Wraps a TF API Class's class method in a `Layer` object.
Reported by Pylint.
Line: 26
Column: 1
from tensorflow.python.platform import tf_logging
from tensorflow.python.util.tf_export import get_canonical_name_for_symbol
from tensorflow.python.util.tf_export import get_symbol_from_name
class ClassMethod(Layer):
"""Wraps a TF API Class's class method in a `Layer` object.
Reported by Pylint.
Line: 69
Column: 3
self._expects_training_arg = False
self._expects_mask_arg = False
def call(self, args, kwargs):
return getattr(self.cls_ref, self.method_name)(*args, **kwargs)
def get_config(self):
if not self.cls_symbol:
raise ValueError(
Reported by Pylint.
Line: 87
Column: 32
return dict(list(base_config.items()) + list(config.items()))
@classmethod
def from_config(cls, config, custom_objects=None):
config = config.copy()
symbol_name = config.pop('cls_symbol')
cls_ref = get_symbol_from_name(symbol_name)
if not cls_ref:
raise ValueError(f'TensorFlow symbol `{symbol_name}` could not be found.')
Reported by Pylint.
keras/tests/temporal_sample_weights_correctness_test.py
222 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests temporal sample weights correctness using Keras model."""
import tensorflow.compat.v2 as tf
import numpy as np
from keras import keras_parameterized
from keras import layers
Reported by Pylint.
Line: 21
Column: 1
import numpy as np
from keras import keras_parameterized
from keras import layers
from keras import metrics
from keras import optimizer_v2
from keras import testing_utils
Reported by Pylint.
Line: 22
Column: 1
import numpy as np
from keras import keras_parameterized
from keras import layers
from keras import metrics
from keras import optimizer_v2
from keras import testing_utils
Reported by Pylint.
Line: 23
Column: 1
from keras import keras_parameterized
from keras import layers
from keras import metrics
from keras import optimizer_v2
from keras import testing_utils
class Bias(layers.Layer):
Reported by Pylint.
Line: 24
Column: 1
from keras import keras_parameterized
from keras import layers
from keras import metrics
from keras import optimizer_v2
from keras import testing_utils
class Bias(layers.Layer):
"""Layer that add a bias to its inputs."""
Reported by Pylint.
Line: 25
Column: 1
from keras import layers
from keras import metrics
from keras import optimizer_v2
from keras import testing_utils
class Bias(layers.Layer):
"""Layer that add a bias to its inputs."""
Reported by Pylint.
Line: 31
Column: 19
class Bias(layers.Layer):
"""Layer that add a bias to its inputs."""
def build(self, input_shape):
self.bias = self.add_variable('bias', (1,), initializer='zeros')
def call(self, inputs):
return inputs + self.bias
Reported by Pylint.
Line: 32
Column: 5
"""Layer that add a bias to its inputs."""
def build(self, input_shape):
self.bias = self.add_variable('bias', (1,), initializer='zeros')
def call(self, inputs):
return inputs + self.bias
def compute_output_shape(self, input_shape):
Reported by Pylint.
Line: 92
Column: 3
sample_weight_mode=[None, 'temporal'])
fn(model)
# TODO(b/129700800): Enable after bug is fixed.
# model = get_compiled_multi_io_model_temporal(sample_weight_mode={
# 'output_2': 'temporal'
# })
# fn(model)
Reported by Pylint.
Line: 29
Column: 1
class Bias(layers.Layer):
"""Layer that add a bias to its inputs."""
def build(self, input_shape):
self.bias = self.add_variable('bias', (1,), initializer='zeros')
def call(self, inputs):
Reported by Pylint.
keras/utils/data_utils_test.py
219 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests for data_utils."""
import tensorflow.compat.v2 as tf
from itertools import cycle
import os
import tarfile
import urllib
Reported by Pylint.
Line: 58
Column: 22
path = keras.utils.data_utils.get_file('test.txt', origin,
untar=True, cache_subdir=dest_dir)
filepath = path + '.tar.gz'
hashval_sha256 = keras.utils.data_utils._hash_file(filepath)
hashval_md5 = keras.utils.data_utils._hash_file(filepath, algorithm='md5')
path = keras.utils.data_utils.get_file(
'test.txt', origin, md5_hash=hashval_md5,
untar=True, cache_subdir=dest_dir)
path = keras.utils.data_utils.get_file(
Reported by Pylint.
Line: 59
Column: 19
untar=True, cache_subdir=dest_dir)
filepath = path + '.tar.gz'
hashval_sha256 = keras.utils.data_utils._hash_file(filepath)
hashval_md5 = keras.utils.data_utils._hash_file(filepath, algorithm='md5')
path = keras.utils.data_utils.get_file(
'test.txt', origin, md5_hash=hashval_md5,
untar=True, cache_subdir=dest_dir)
path = keras.utils.data_utils.get_file(
filepath, origin, file_hash=hashval_sha256,
Reported by Pylint.
Line: 75
Column: 22
origin = urllib.parse.urljoin(
'file://', urllib.request.pathname2url(os.path.abspath(zip_file_path)))
hashval_sha256 = keras.utils.data_utils._hash_file(zip_file_path)
hashval_md5 = keras.utils.data_utils._hash_file(zip_file_path,
algorithm='md5')
path = keras.utils.data_utils.get_file(
'test', origin, md5_hash=hashval_md5,
extract=True, cache_subdir=dest_dir)
Reported by Pylint.
Line: 76
Column: 19
'file://', urllib.request.pathname2url(os.path.abspath(zip_file_path)))
hashval_sha256 = keras.utils.data_utils._hash_file(zip_file_path)
hashval_md5 = keras.utils.data_utils._hash_file(zip_file_path,
algorithm='md5')
path = keras.utils.data_utils.get_file(
'test', origin, md5_hash=hashval_md5,
extract=True, cache_subdir=dest_dir)
path = keras.utils.data_utils.get_file(
Reported by Pylint.
Line: 93
Column: 24
(zip_file_path, True)]:
origin = urllib.parse.urljoin(
'file://', urllib.request.pathname2url(os.path.abspath(file_path)))
hashval_sha256 = keras.utils.data_utils._hash_file(file_path)
path = keras.utils.data_utils.get_file(
origin=origin,
file_hash=hashval_sha256,
extract=extract,
cache_subdir=dest_dir)
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
from itertools import cycle
import os
import tarfile
import urllib
import zipfile
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
from itertools import cycle
import os
import tarfile
import urllib
import zipfile
import numpy as np
Reported by Pylint.
Line: 21
Column: 1
from itertools import cycle
import os
import tarfile
import urllib
import zipfile
import numpy as np
Reported by Pylint.
Line: 22
Column: 1
from itertools import cycle
import os
import tarfile
import urllib
import zipfile
import numpy as np
import keras
Reported by Pylint.
keras/layers/kernelized_test.py
213 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests for kernelized.py."""
import tensorflow.compat.v2 as tf
import functools
import math
import os
import shutil
Reported by Pylint.
Line: 24
Column: 1
import os
import shutil
from absl.testing import parameterized
import numpy as np
from tensorflow.python.framework import test_util
from keras import backend as keras_backend
from keras import combinations
from keras import initializers
Reported by Pylint.
Line: 26
Column: 1
from absl.testing import parameterized
import numpy as np
from tensorflow.python.framework import test_util
from keras import backend as keras_backend
from keras import combinations
from keras import initializers
from keras import testing_utils
from keras.engine import base_layer_utils
Reported by Pylint.
Line: 55
Column: 9
def _assert_all_close(self, expected, actual, atol=0.001):
if not tf.executing_eagerly():
with self.cached_session() as sess:
keras_backend._initialize_variables(sess)
self.assertAllClose(expected, actual, atol=atol)
else:
self.assertAllClose(expected, actual, atol=atol)
@testing_utils.run_v2_only
Reported by Pylint.
Line: 343
Column: 9
abs_error = tf.abs(exact_kernel_value - approx_kernel_value)
if not tf.executing_eagerly():
with self.cached_session() as sess:
keras_backend._initialize_variables(sess)
abs_error_eval = sess.run([abs_error])
self.assertGreater(abs_error_eval[0][0], 0.05)
self.assertLess(abs_error_eval[0][0], 0.5)
else:
self.assertGreater(abs_error, 0.05)
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
import functools
import math
import os
import shutil
from absl.testing import parameterized
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
import functools
import math
import os
import shutil
from absl.testing import parameterized
import numpy as np
Reported by Pylint.
Line: 21
Column: 1
import functools
import math
import os
import shutil
from absl.testing import parameterized
import numpy as np
from tensorflow.python.framework import test_util
Reported by Pylint.
Line: 22
Column: 1
import functools
import math
import os
import shutil
from absl.testing import parameterized
import numpy as np
from tensorflow.python.framework import test_util
from keras import backend as keras_backend
Reported by Pylint.
Line: 40
Column: 1
def _exact_gaussian(stddev):
return functools.partial(
kernelized_utils.exact_gaussian_kernel, stddev=stddev)
def _exact_laplacian(stddev):
return functools.partial(
Reported by Pylint.
keras/benchmarks/model_components_benchmarks_test.py
212 issues
Line: 17
Column: 1
# ==============================================================================
r"""Benchmarks on Keras components with different Keras model types."""
import tensorflow as tf
import time
import numpy as np
Reported by Pylint.
Line: 23
Column: 1
import numpy as np
from tensorflow.python.eager import context
from tensorflow.python.eager.context import get_executor
class SubclassedKerasModel(tf.keras.Model):
Reported by Pylint.
Line: 24
Column: 1
import numpy as np
from tensorflow.python.eager import context
from tensorflow.python.eager.context import get_executor
class SubclassedKerasModel(tf.keras.Model):
def __init__(self, initializer="ones"):
Reported by Pylint.
Line: 19
Column: 1
import tensorflow as tf
import time
import numpy as np
from tensorflow.python.eager import context
from tensorflow.python.eager.context import get_executor
Reported by Pylint.
Line: 27
Column: 1
from tensorflow.python.eager.context import get_executor
class SubclassedKerasModel(tf.keras.Model):
def __init__(self, initializer="ones"):
super(SubclassedKerasModel, self).__init__()
self.layer_a = tf.keras.layers.Dense(
64, kernel_initializer=initializer, bias_initializer="zeros")
Reported by Pylint.
Line: 27
Column: 1
from tensorflow.python.eager.context import get_executor
class SubclassedKerasModel(tf.keras.Model):
def __init__(self, initializer="ones"):
super(SubclassedKerasModel, self).__init__()
self.layer_a = tf.keras.layers.Dense(
64, kernel_initializer=initializer, bias_initializer="zeros")
Reported by Pylint.
Line: 29
Column: 1
class SubclassedKerasModel(tf.keras.Model):
def __init__(self, initializer="ones"):
super(SubclassedKerasModel, self).__init__()
self.layer_a = tf.keras.layers.Dense(
64, kernel_initializer=initializer, bias_initializer="zeros")
self.layer_b = tf.keras.layers.Dense(
128, kernel_initializer=initializer, bias_initializer="zeros")
Reported by Pylint.
Line: 30
Column: 5
class SubclassedKerasModel(tf.keras.Model):
def __init__(self, initializer="ones"):
super(SubclassedKerasModel, self).__init__()
self.layer_a = tf.keras.layers.Dense(
64, kernel_initializer=initializer, bias_initializer="zeros")
self.layer_b = tf.keras.layers.Dense(
128, kernel_initializer=initializer, bias_initializer="zeros")
self.layer_c = tf.keras.layers.Dense(
Reported by Pylint.
Line: 30
Column: 1
class SubclassedKerasModel(tf.keras.Model):
def __init__(self, initializer="ones"):
super(SubclassedKerasModel, self).__init__()
self.layer_a = tf.keras.layers.Dense(
64, kernel_initializer=initializer, bias_initializer="zeros")
self.layer_b = tf.keras.layers.Dense(
128, kernel_initializer=initializer, bias_initializer="zeros")
self.layer_c = tf.keras.layers.Dense(
Reported by Pylint.
Line: 31
Column: 1
def __init__(self, initializer="ones"):
super(SubclassedKerasModel, self).__init__()
self.layer_a = tf.keras.layers.Dense(
64, kernel_initializer=initializer, bias_initializer="zeros")
self.layer_b = tf.keras.layers.Dense(
128, kernel_initializer=initializer, bias_initializer="zeros")
self.layer_c = tf.keras.layers.Dense(
256, kernel_initializer=initializer, bias_initializer="zeros")
Reported by Pylint.