The following issues were found
keras/engine/training_gpu_test.py
57 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests for training routines."""
import tensorflow.compat.v2 as tf
from absl.testing import parameterized
import numpy as np
from keras import backend
from keras import combinations
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 backend
from keras import combinations
from keras import testing_utils
from keras.engine import input_layer
Reported by Pylint.
Line: 46
Column: 1
num_channels = None
activation = None
if loss_name == 'sparse_categorical_crossentropy':
loss = lambda y_true, y_pred: backend.sparse_categorical_crossentropy( # pylint: disable=g-long-lambda
y_true, y_pred, axis=axis)
num_channels = int(np.amax(target) + 1)
activation = 'softmax'
elif loss_name == 'categorical_crossentropy':
loss = lambda y_true, y_pred: backend.categorical_crossentropy( # pylint: disable=g-long-lambda
Reported by Pylint.
Line: 51
Column: 1
num_channels = int(np.amax(target) + 1)
activation = 'softmax'
elif loss_name == 'categorical_crossentropy':
loss = lambda y_true, y_pred: backend.categorical_crossentropy( # pylint: disable=g-long-lambda
y_true, y_pred, axis=axis)
num_channels = target.shape[axis]
activation = 'softmax'
elif loss_name == 'binary_crossentropy':
loss = lambda y_true, y_pred: backend.binary_crossentropy( # pylint: disable=g-long-lambda, unnecessary-lambda
Reported by Pylint.
Line: 56
Column: 1
num_channels = target.shape[axis]
activation = 'softmax'
elif loss_name == 'binary_crossentropy':
loss = lambda y_true, y_pred: backend.binary_crossentropy( # pylint: disable=g-long-lambda, unnecessary-lambda
y_true, y_pred)
num_channels = target.shape[axis]
activation = 'sigmoid'
predictions = Conv2D(num_channels,
Reported by Pylint.
Line: 29
Column: 1
from keras.layers.convolutional import Conv2D
class TrainingGPUTest(tf.test.TestCase, parameterized.TestCase):
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
def test_model_with_crossentropy_losses_channels_first(self):
"""Tests use of all crossentropy losses with `channels_first`.
Reported by Pylint.
Line: 29
Column: 1
from keras.layers.convolutional import Conv2D
class TrainingGPUTest(tf.test.TestCase, parameterized.TestCase):
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
def test_model_with_crossentropy_losses_channels_first(self):
"""Tests use of all crossentropy losses with `channels_first`.
Reported by Pylint.
Line: 31
Column: 1
class TrainingGPUTest(tf.test.TestCase, parameterized.TestCase):
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
def test_model_with_crossentropy_losses_channels_first(self):
"""Tests use of all crossentropy losses with `channels_first`.
Tests `sparse_categorical_crossentropy`, `categorical_crossentropy`,
and `binary_crossentropy`.
Reported by Pylint.
Line: 32
Column: 1
class TrainingGPUTest(tf.test.TestCase, parameterized.TestCase):
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
def test_model_with_crossentropy_losses_channels_first(self):
"""Tests use of all crossentropy losses with `channels_first`.
Tests `sparse_categorical_crossentropy`, `categorical_crossentropy`,
and `binary_crossentropy`.
Verifies that evaluate gives the same result with either `channels_first`
Reported by Pylint.
Line: 32
Column: 3
class TrainingGPUTest(tf.test.TestCase, parameterized.TestCase):
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
def test_model_with_crossentropy_losses_channels_first(self):
"""Tests use of all crossentropy losses with `channels_first`.
Tests `sparse_categorical_crossentropy`, `categorical_crossentropy`,
and `binary_crossentropy`.
Verifies that evaluate gives the same result with either `channels_first`
Reported by Pylint.
keras/distribute/mirrored_variable_test.py
57 issues
Line: 17
Column: 1
# ==============================================================================
"""Test MirroredVariable in MirroredStrategy and MultiWorkerMirroredStrategy."""
import tensorflow.compat.v2 as tf
from keras.distribute import distributed_training_utils
from keras.layers import core
def _mimic_two_cpus():
Reported by Pylint.
Line: 39
Column: 11
def get_strategy_with_mimicing_cpus():
if not _mimic_two_cpus():
return None
return (tf.distribute.MultiWorkerMirroredStrategy
._from_local_devices(("/device:CPU:0", "/device:CPU:1")))
@tf.__internal__.distribute.combinations.generate(
tf.__internal__.test.combinations.combine(
Reported by Pylint.
Line: 23
Column: 1
def _mimic_two_cpus():
try:
cpus = tf.config.list_physical_devices("CPU")
except tf.errors.NotFoundError:
# Testing device not available. Skip the test.
return False
Reported by Pylint.
Line: 24
Column: 1
def _mimic_two_cpus():
try:
cpus = tf.config.list_physical_devices("CPU")
except tf.errors.NotFoundError:
# Testing device not available. Skip the test.
return False
tf.config.set_logical_device_configuration(cpus[0], [
Reported by Pylint.
Line: 25
Column: 1
def _mimic_two_cpus():
try:
cpus = tf.config.list_physical_devices("CPU")
except tf.errors.NotFoundError:
# Testing device not available. Skip the test.
return False
tf.config.set_logical_device_configuration(cpus[0], [
tf.config.LogicalDeviceConfiguration(),
Reported by Pylint.
Line: 27
Column: 1
cpus = tf.config.list_physical_devices("CPU")
except tf.errors.NotFoundError:
# Testing device not available. Skip the test.
return False
tf.config.set_logical_device_configuration(cpus[0], [
tf.config.LogicalDeviceConfiguration(),
tf.config.LogicalDeviceConfiguration(),
])
Reported by Pylint.
Line: 29
Column: 1
# Testing device not available. Skip the test.
return False
tf.config.set_logical_device_configuration(cpus[0], [
tf.config.LogicalDeviceConfiguration(),
tf.config.LogicalDeviceConfiguration(),
])
return True
Reported by Pylint.
Line: 33
Column: 1
tf.config.LogicalDeviceConfiguration(),
tf.config.LogicalDeviceConfiguration(),
])
return True
def get_strategy_with_mimicing_cpus():
if not _mimic_two_cpus():
return None
Reported by Pylint.
Line: 36
Column: 1
return True
def get_strategy_with_mimicing_cpus():
if not _mimic_two_cpus():
return None
return (tf.distribute.MultiWorkerMirroredStrategy
._from_local_devices(("/device:CPU:0", "/device:CPU:1")))
Reported by Pylint.
Line: 37
Column: 1
def get_strategy_with_mimicing_cpus():
if not _mimic_two_cpus():
return None
return (tf.distribute.MultiWorkerMirroredStrategy
._from_local_devices(("/device:CPU:0", "/device:CPU:1")))
Reported by Pylint.
keras/layers/core/flatten.py
57 issues
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
"""Contains the flatten layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import
import functools
import operator
from keras.engine.base_layer import Layer
from keras.engine.input_spec import InputSpec
Reported by Pylint.
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
"""Contains the flatten layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import
import functools
import operator
from keras.engine.base_layer import Layer
from keras.engine.input_spec import InputSpec
Reported by Pylint.
Line: 24
Column: 1
from keras.engine.input_spec import InputSpec
from keras.utils import conv_utils
import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export
@keras_export('keras.layers.Flatten')
class Flatten(Layer):
Reported by Pylint.
Line: 25
Column: 1
from keras.utils import conv_utils
import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export
@keras_export('keras.layers.Flatten')
class Flatten(Layer):
"""Flattens the input. Does not affect the batch size.
Reported by Pylint.
Line: 65
Column: 3
self.input_spec = InputSpec(min_ndim=1)
self._channels_first = self.data_format == 'channels_first'
def call(self, inputs):
if self._channels_first:
rank = inputs.shape.rank
if rank and rank > 1:
# Switch to channels-last format.
permutation = [0]
Reported by Pylint.
Line: 30
Column: 1
@keras_export('keras.layers.Flatten')
class Flatten(Layer):
"""Flattens the input. Does not affect the batch size.
Note: If inputs are shaped `(batch,)` without a feature axis, then
flattening adds an extra channel dimension and output shape is `(batch, 1)`.
Args:
Reported by Pylint.
Line: 59
Column: 1
"""
def __init__(self, data_format=None, **kwargs):
super(Flatten, self).__init__(**kwargs)
self.data_format = conv_utils.normalize_data_format(data_format)
self.input_spec = InputSpec(min_ndim=1)
self._channels_first = self.data_format == 'channels_first'
Reported by Pylint.
Line: 60
Column: 5
"""
def __init__(self, data_format=None, **kwargs):
super(Flatten, self).__init__(**kwargs)
self.data_format = conv_utils.normalize_data_format(data_format)
self.input_spec = InputSpec(min_ndim=1)
self._channels_first = self.data_format == 'channels_first'
def call(self, inputs):
Reported by Pylint.
Line: 60
Column: 1
"""
def __init__(self, data_format=None, **kwargs):
super(Flatten, self).__init__(**kwargs)
self.data_format = conv_utils.normalize_data_format(data_format)
self.input_spec = InputSpec(min_ndim=1)
self._channels_first = self.data_format == 'channels_first'
def call(self, inputs):
Reported by Pylint.
Line: 61
Column: 1
def __init__(self, data_format=None, **kwargs):
super(Flatten, self).__init__(**kwargs)
self.data_format = conv_utils.normalize_data_format(data_format)
self.input_spec = InputSpec(min_ndim=1)
self._channels_first = self.data_format == 'channels_first'
def call(self, inputs):
if self._channels_first:
Reported by Pylint.
keras/layers/noise_test.py
56 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests for noise layers."""
import tensorflow.compat.v2 as tf
import numpy as np
import keras
from keras import keras_parameterized
Reported by Pylint.
Line: 27
Column: 1
@keras_parameterized.run_all_keras_modes
class NoiseLayersTest(keras_parameterized.TestCase):
def test_GaussianNoise(self):
testing_utils.layer_test(
keras.layers.GaussianNoise,
kwargs={'stddev': 1.},
Reported by Pylint.
Line: 29
Column: 3
@keras_parameterized.run_all_keras_modes
class NoiseLayersTest(keras_parameterized.TestCase):
def test_GaussianNoise(self):
testing_utils.layer_test(
keras.layers.GaussianNoise,
kwargs={'stddev': 1.},
input_shape=(3, 2, 3))
Reported by Pylint.
Line: 29
Column: 1
@keras_parameterized.run_all_keras_modes
class NoiseLayersTest(keras_parameterized.TestCase):
def test_GaussianNoise(self):
testing_utils.layer_test(
keras.layers.GaussianNoise,
kwargs={'stddev': 1.},
input_shape=(3, 2, 3))
Reported by Pylint.
Line: 29
Column: 3
@keras_parameterized.run_all_keras_modes
class NoiseLayersTest(keras_parameterized.TestCase):
def test_GaussianNoise(self):
testing_utils.layer_test(
keras.layers.GaussianNoise,
kwargs={'stddev': 1.},
input_shape=(3, 2, 3))
Reported by Pylint.
Line: 29
Column: 3
@keras_parameterized.run_all_keras_modes
class NoiseLayersTest(keras_parameterized.TestCase):
def test_GaussianNoise(self):
testing_utils.layer_test(
keras.layers.GaussianNoise,
kwargs={'stddev': 1.},
input_shape=(3, 2, 3))
Reported by Pylint.
Line: 30
Column: 1
class NoiseLayersTest(keras_parameterized.TestCase):
def test_GaussianNoise(self):
testing_utils.layer_test(
keras.layers.GaussianNoise,
kwargs={'stddev': 1.},
input_shape=(3, 2, 3))
def test_GaussianDropout(self):
Reported by Pylint.
Line: 35
Column: 1
kwargs={'stddev': 1.},
input_shape=(3, 2, 3))
def test_GaussianDropout(self):
testing_utils.layer_test(
keras.layers.GaussianDropout,
kwargs={'rate': 0.5},
input_shape=(3, 2, 3))
Reported by Pylint.
Line: 35
Column: 3
kwargs={'stddev': 1.},
input_shape=(3, 2, 3))
def test_GaussianDropout(self):
testing_utils.layer_test(
keras.layers.GaussianDropout,
kwargs={'rate': 0.5},
input_shape=(3, 2, 3))
Reported by Pylint.
Line: 35
Column: 3
kwargs={'stddev': 1.},
input_shape=(3, 2, 3))
def test_GaussianDropout(self):
testing_utils.layer_test(
keras.layers.GaussianDropout,
kwargs={'rate': 0.5},
input_shape=(3, 2, 3))
Reported by Pylint.
keras/optimizer_v2/gradient_descent.py
55 issues
Line: 17
Column: 1
# ==============================================================================
"""SGD optimizer implementation."""
import tensorflow.compat.v2 as tf
from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export
@keras_export("keras.optimizers.SGD")
Reported by Pylint.
Line: 18
Column: 1
"""SGD optimizer implementation."""
import tensorflow.compat.v2 as tf
from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export
@keras_export("keras.optimizers.SGD")
class SGD(optimizer_v2.OptimizerV2):
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
from keras.optimizer_v2 import optimizer_v2
from tensorflow.python.util.tf_export import keras_export
@keras_export("keras.optimizers.SGD")
class SGD(optimizer_v2.OptimizerV2):
r"""Gradient descent (with momentum) optimizer.
Reported by Pylint.
Line: 23
Column: 1
@keras_export("keras.optimizers.SGD")
class SGD(optimizer_v2.OptimizerV2):
r"""Gradient descent (with momentum) optimizer.
Update rule for parameter `w` with gradient `g` when `momentum` is 0:
```python
Reported by Pylint.
Line: 24
Column: 1
@keras_export("keras.optimizers.SGD")
class SGD(optimizer_v2.OptimizerV2):
r"""Gradient descent (with momentum) optimizer.
Update rule for parameter `w` with gradient `g` when `momentum` is 0:
```python
w = w - learning_rate * g
Reported by Pylint.
Line: 94
Column: 1
http://jmlr.org/proceedings/papers/v28/sutskever13.pdf).
"""
_HAS_AGGREGATE_GRAD = True
def __init__(self,
learning_rate=0.01,
momentum=0.0,
nesterov=False,
Reported by Pylint.
Line: 96
Column: 1
_HAS_AGGREGATE_GRAD = True
def __init__(self,
learning_rate=0.01,
momentum=0.0,
nesterov=False,
name="SGD",
**kwargs):
Reported by Pylint.
Line: 102
Column: 1
nesterov=False,
name="SGD",
**kwargs):
super(SGD, self).__init__(name, **kwargs)
self._set_hyper("learning_rate", kwargs.get("lr", learning_rate))
self._set_hyper("decay", self._initial_decay)
self._momentum = False
if isinstance(momentum, tf.Tensor) or callable(momentum) or momentum > 0:
Reported by Pylint.
Line: 102
Column: 5
nesterov=False,
name="SGD",
**kwargs):
super(SGD, self).__init__(name, **kwargs)
self._set_hyper("learning_rate", kwargs.get("lr", learning_rate))
self._set_hyper("decay", self._initial_decay)
self._momentum = False
if isinstance(momentum, tf.Tensor) or callable(momentum) or momentum > 0:
Reported by Pylint.
Line: 103
Column: 1
name="SGD",
**kwargs):
super(SGD, self).__init__(name, **kwargs)
self._set_hyper("learning_rate", kwargs.get("lr", learning_rate))
self._set_hyper("decay", self._initial_decay)
self._momentum = False
if isinstance(momentum, tf.Tensor) or callable(momentum) or momentum > 0:
self._momentum = True
Reported by Pylint.
keras/initializers/initializers_v1.py
55 issues
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
"""Keras initializers for TF 1."""
# pylint:disable=g-classes-have-attributes
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export
Reported by Pylint.
Line: 18
Column: 1
"""Keras initializers for TF 1."""
# pylint:disable=g-classes-have-attributes
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export
_v1_zeros_initializer = tf.compat.v1.zeros_initializer
_v1_ones_initializer = tf.compat.v1.ones_initializer
Reported by Pylint.
Line: 19
Column: 1
# pylint:disable=g-classes-have-attributes
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export
_v1_zeros_initializer = tf.compat.v1.zeros_initializer
_v1_ones_initializer = tf.compat.v1.ones_initializer
_v1_constant_initializer = tf.compat.v1.constant_initializer
Reported by Pylint.
Line: 31
Column: 1
_v1_glorot_uniform_initializer = tf.compat.v1.glorot_uniform_initializer
_v1_glorot_normal_initializer = tf.compat.v1.glorot_normal_initializer
keras_export(v1=['keras.initializers.Zeros', 'keras.initializers.zeros'], allow_multiple_exports=True)(
_v1_zeros_initializer)
keras_export(v1=['keras.initializers.Ones', 'keras.initializers.ones'], allow_multiple_exports=True)(
_v1_ones_initializer)
keras_export(v1=['keras.initializers.Constant', 'keras.initializers.constant'], allow_multiple_exports=True)(
_v1_constant_initializer)
Reported by Pylint.
Line: 33
Column: 1
keras_export(v1=['keras.initializers.Zeros', 'keras.initializers.zeros'], allow_multiple_exports=True)(
_v1_zeros_initializer)
keras_export(v1=['keras.initializers.Ones', 'keras.initializers.ones'], allow_multiple_exports=True)(
_v1_ones_initializer)
keras_export(v1=['keras.initializers.Constant', 'keras.initializers.constant'], allow_multiple_exports=True)(
_v1_constant_initializer)
keras_export(v1=['keras.initializers.VarianceScaling'], allow_multiple_exports=True)(
_v1_variance_scaling_initializer)
Reported by Pylint.
Line: 35
Column: 1
_v1_zeros_initializer)
keras_export(v1=['keras.initializers.Ones', 'keras.initializers.ones'], allow_multiple_exports=True)(
_v1_ones_initializer)
keras_export(v1=['keras.initializers.Constant', 'keras.initializers.constant'], allow_multiple_exports=True)(
_v1_constant_initializer)
keras_export(v1=['keras.initializers.VarianceScaling'], allow_multiple_exports=True)(
_v1_variance_scaling_initializer)
keras_export(v1=['keras.initializers.Orthogonal',
'keras.initializers.orthogonal'], allow_multiple_exports=True)(_v1_orthogonal_initializer)
Reported by Pylint.
Line: 40
Column: 1
keras_export(v1=['keras.initializers.VarianceScaling'], allow_multiple_exports=True)(
_v1_variance_scaling_initializer)
keras_export(v1=['keras.initializers.Orthogonal',
'keras.initializers.orthogonal'], allow_multiple_exports=True)(_v1_orthogonal_initializer)
keras_export(v1=['keras.initializers.Identity',
'keras.initializers.identity'], allow_multiple_exports=True)(_v1_identity)
keras_export(v1=['keras.initializers.glorot_uniform'], allow_multiple_exports=True)(
_v1_glorot_uniform_initializer)
keras_export(v1=['keras.initializers.glorot_normal'], allow_multiple_exports=True)(
Reported by Pylint.
Line: 52
Column: 1
@keras_export(v1=['keras.initializers.RandomNormal',
'keras.initializers.random_normal',
'keras.initializers.normal'])
class RandomNormal(tf.compat.v1.random_normal_initializer):
"""Initializer that generates a normal distribution.
Args:
mean: a python scalar or a scalar tensor. Mean of the random values to
generate.
Reported by Pylint.
Line: 53
Column: 1
'keras.initializers.random_normal',
'keras.initializers.normal'])
class RandomNormal(tf.compat.v1.random_normal_initializer):
"""Initializer that generates a normal distribution.
Args:
mean: a python scalar or a scalar tensor. Mean of the random values to
generate.
stddev: a python scalar or a scalar tensor. Standard deviation of the random
Reported by Pylint.
Line: 158
Column: 1
@end_compatibility
"""
def __init__(self, mean=0.0, stddev=0.05, seed=None, dtype=tf.float32):
super(RandomNormal, self).__init__(
mean=mean, stddev=stddev, seed=seed, dtype=dtype)
@keras_export(v1=['keras.initializers.RandomUniform',
Reported by Pylint.
keras/distribute/sidecar_evaluator.py
52 issues
Line: 18
Column: 1
# ==============================================================================
"""Python module for evaluation loop."""
import tensorflow.compat.v2 as tf
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export # pylint: disable=g-direct-tensorflow-import
_PRINT_EVAL_STEP_EVERY_SEC = 60.0
_ITERATIONS_UNINITIALIZED = -1
Reported by Pylint.
Line: 19
Column: 1
"""Python module for evaluation loop."""
import tensorflow.compat.v2 as tf
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export # pylint: disable=g-direct-tensorflow-import
_PRINT_EVAL_STEP_EVERY_SEC = 60.0
_ITERATIONS_UNINITIALIZED = -1
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export # pylint: disable=g-direct-tensorflow-import
_PRINT_EVAL_STEP_EVERY_SEC = 60.0
_ITERATIONS_UNINITIALIZED = -1
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export # pylint: disable=g-direct-tensorflow-import
_PRINT_EVAL_STEP_EVERY_SEC = 60.0
_ITERATIONS_UNINITIALIZED = -1
Reported by Pylint.
Line: 206
Column: 3
# 1) OpError: open failed for <file path>: No such file or directory
# 2) NotFoundError (subclass of OpError): Unsuccessful
# TensorSliceReader constructor.
# TODO(rchao): Remove this except block once b/150954027 is resolved.
logging.info(
'SidecarEvaluator encountered an error when loading the checkpoint '
f'at {latest_checkpoint}. Retrying. '
f'Error: {e.__class__.__name__}: {e}')
continue
Reported by Pylint.
Line: 27
Column: 1
def list_checkpoint_attributes(ckpt_dir_or_file):
"""Lists all the attributes in a checkpoint.
Checkpoint keys are paths in a checkpoint graph, and attribute is the first
element in the path. e.g. with a checkpoint key
"optimizer/iter/.ATTRIBUTES/VARIABLE_VALUE", optimizer is the attribute. The
attribute is also used to save/restore a variable in a checkpoint,
Reported by Pylint.
Line: 41
Column: 1
Returns:
Set of attributes in a checkpoint.
"""
reader = tf.train.load_checkpoint(ckpt_dir_or_file)
variable_map = reader.get_variable_to_shape_map()
return {name.split('/')[0] for name in variable_map.keys()}
@keras_export('keras.experimental.SidecarEvaluator', v1=[])
Reported by Pylint.
Line: 42
Column: 1
Set of attributes in a checkpoint.
"""
reader = tf.train.load_checkpoint(ckpt_dir_or_file)
variable_map = reader.get_variable_to_shape_map()
return {name.split('/')[0] for name in variable_map.keys()}
@keras_export('keras.experimental.SidecarEvaluator', v1=[])
class SidecarEvaluator:
Reported by Pylint.
Line: 43
Column: 1
"""
reader = tf.train.load_checkpoint(ckpt_dir_or_file)
variable_map = reader.get_variable_to_shape_map()
return {name.split('/')[0] for name in variable_map.keys()}
@keras_export('keras.experimental.SidecarEvaluator', v1=[])
class SidecarEvaluator:
"""A class designed for a dedicated evaluator task.
Reported by Pylint.
Line: 47
Column: 1
@keras_export('keras.experimental.SidecarEvaluator', v1=[])
class SidecarEvaluator:
"""A class designed for a dedicated evaluator task.
`SidecarEvaluator` is expected to be run in a process on a separate machine
from the training cluster. It is meant for the purpose of a dedicated
evaluator, evaluating the metric results of a training cluster which has one
Reported by Pylint.
keras/mixed_precision/device_compatibility_check_test.py
52 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests the device compatibility check."""
import tensorflow.compat.v2 as tf
import re
from keras import combinations
from keras.mixed_precision import device_compatibility_check
Reported by Pylint.
Line: 23
Column: 1
from keras import combinations
from keras.mixed_precision import device_compatibility_check
from tensorflow.python.platform import tf_logging
def device_details(device_name, compute_capability=None):
details = {}
if device_name:
Reported by Pylint.
Line: 42
Column: 7
policy_name='mixed_float16'):
with tf.compat.v1.test.mock.patch.object(tf_logging, 'warning') as mock_warn, \
tf.compat.v1.test.mock.patch.object(tf_logging, 'info') as mock_info:
device_compatibility_check._log_device_compatibility_check(
policy_name, device_attr_list)
if should_warn:
self.assertRegex(mock_warn.call_args[0][0], expected_regex)
mock_info.assert_not_called()
else:
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
import re
from keras import combinations
from keras.mixed_precision import device_compatibility_check
from tensorflow.python.platform import tf_logging
Reported by Pylint.
Line: 26
Column: 1
from tensorflow.python.platform import tf_logging
def device_details(device_name, compute_capability=None):
details = {}
if device_name:
details['device_name'] = device_name
if compute_capability:
details['compute_capability'] = compute_capability
Reported by Pylint.
Line: 27
Column: 1
def device_details(device_name, compute_capability=None):
details = {}
if device_name:
details['device_name'] = device_name
if compute_capability:
details['compute_capability'] = compute_capability
return details
Reported by Pylint.
Line: 28
Column: 1
def device_details(device_name, compute_capability=None):
details = {}
if device_name:
details['device_name'] = device_name
if compute_capability:
details['compute_capability'] = compute_capability
return details
Reported by Pylint.
Line: 29
Column: 1
def device_details(device_name, compute_capability=None):
details = {}
if device_name:
details['device_name'] = device_name
if compute_capability:
details['compute_capability'] = compute_capability
return details
Reported by Pylint.
Line: 30
Column: 1
details = {}
if device_name:
details['device_name'] = device_name
if compute_capability:
details['compute_capability'] = compute_capability
return details
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
Reported by Pylint.
Line: 31
Column: 1
if device_name:
details['device_name'] = device_name
if compute_capability:
details['compute_capability'] = compute_capability
return details
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
class DeviceCompatibilityCheckTest(tf.test.TestCase):
Reported by Pylint.
keras/layers/core/reshape.py
52 issues
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
"""Contains the Reshape layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import
from keras.engine.base_layer import Layer
import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export
Reported by Pylint.
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
"""Contains the Reshape layer."""
# pylint: disable=g-classes-have-attributes,g-direct-tensorflow-import
from keras.engine.base_layer import Layer
import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export
Reported by Pylint.
Line: 20
Column: 1
from keras.engine.base_layer import Layer
import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export
@keras_export('keras.layers.Reshape')
class Reshape(Layer):
Reported by Pylint.
Line: 21
Column: 1
from keras.engine.base_layer import Layer
import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.util.tf_export import keras_export
@keras_export('keras.layers.Reshape')
class Reshape(Layer):
"""Layer that reshapes inputs into the given shape.
Reported by Pylint.
Line: 125
Column: 3
self.target_shape)
return tf.TensorShape(output_shape)
def call(self, inputs):
result = tf.reshape(inputs, (tf.shape(inputs)[0],) + self.target_shape)
if not tf.executing_eagerly():
# Set the static shape for the result since it might lost during array_ops
# reshape, eg, some `None` dim in the result could be inferred.
result.set_shape(self.compute_output_shape(inputs.shape))
Reported by Pylint.
Line: 26
Column: 1
@keras_export('keras.layers.Reshape')
class Reshape(Layer):
"""Layer that reshapes inputs into the given shape.
Input shape:
Arbitrary, although all dimensions in the input shape must be known/fixed.
Use the keyword argument `input_shape` (tuple of integers, does not include
the samples/batch size axis) when using this layer as the first layer
Reported by Pylint.
Line: 57
Column: 1
(None, 3, 2, 2)
"""
def __init__(self, target_shape, **kwargs):
"""Creates a `tf.keras.layers.Reshape` layer instance.
Args:
target_shape: Target shape. Tuple of integers, does not include the
samples dimension (batch size).
Reported by Pylint.
Line: 58
Column: 1
"""
def __init__(self, target_shape, **kwargs):
"""Creates a `tf.keras.layers.Reshape` layer instance.
Args:
target_shape: Target shape. Tuple of integers, does not include the
samples dimension (batch size).
**kwargs: Any additional layer keyword arguments.
Reported by Pylint.
Line: 65
Column: 5
samples dimension (batch size).
**kwargs: Any additional layer keyword arguments.
"""
super(Reshape, self).__init__(**kwargs)
self.target_shape = tuple(target_shape)
def _fix_unknown_dimension(self, input_shape, output_shape):
"""Find and replace a missing dimension in an output shape.
Reported by Pylint.
Line: 65
Column: 1
samples dimension (batch size).
**kwargs: Any additional layer keyword arguments.
"""
super(Reshape, self).__init__(**kwargs)
self.target_shape = tuple(target_shape)
def _fix_unknown_dimension(self, input_shape, output_shape):
"""Find and replace a missing dimension in an output shape.
Reported by Pylint.
keras/integration_test/preprocessing_test_utils.py
52 issues
Line: 19
Column: 1
import os
import tensorflow as tf
preprocessing = tf.keras.layers
BATCH_SIZE = 64
DS_SIZE = BATCH_SIZE * 16
STEPS = DS_SIZE / BATCH_SIZE
Reported by Pylint.
Line: 29
Column: 1
def make_dataset():
"""Make a simple structured dataset.
The dataset contains three feature columns.
- float_col: an unnormalized numeric column.
- int_col: an column of integer IDs.
- string_col: a column of fixed vocabulary terms.
Reported by Pylint.
Line: 39
Column: 1
Returns:
The dataset.
"""
tf.random.set_seed(197011)
floats = tf.random.uniform((DS_SIZE, 1), maxval=10, dtype="float64")
# Generate a 100 unique integer values, but over a wide range to showcase a
# common use case for IntegerLookup.
ints = tf.random.uniform((DS_SIZE, 1), maxval=VOCAB_SIZE, dtype="int64")
ints = ints * 1000
Reported by Pylint.
Line: 40
Column: 1
The dataset.
"""
tf.random.set_seed(197011)
floats = tf.random.uniform((DS_SIZE, 1), maxval=10, dtype="float64")
# Generate a 100 unique integer values, but over a wide range to showcase a
# common use case for IntegerLookup.
ints = tf.random.uniform((DS_SIZE, 1), maxval=VOCAB_SIZE, dtype="int64")
ints = ints * 1000
# Use a fixed vocabulary of strings from 0 to 99, to showcase loading a
Reported by Pylint.
Line: 43
Column: 1
floats = tf.random.uniform((DS_SIZE, 1), maxval=10, dtype="float64")
# Generate a 100 unique integer values, but over a wide range to showcase a
# common use case for IntegerLookup.
ints = tf.random.uniform((DS_SIZE, 1), maxval=VOCAB_SIZE, dtype="int64")
ints = ints * 1000
# Use a fixed vocabulary of strings from 0 to 99, to showcase loading a
# vocabulary from a file.
strings = tf.random.uniform((DS_SIZE, 1), maxval=VOCAB_SIZE, dtype="int64")
strings = tf.strings.as_string(strings)
Reported by Pylint.
Line: 44
Column: 1
# Generate a 100 unique integer values, but over a wide range to showcase a
# common use case for IntegerLookup.
ints = tf.random.uniform((DS_SIZE, 1), maxval=VOCAB_SIZE, dtype="int64")
ints = ints * 1000
# Use a fixed vocabulary of strings from 0 to 99, to showcase loading a
# vocabulary from a file.
strings = tf.random.uniform((DS_SIZE, 1), maxval=VOCAB_SIZE, dtype="int64")
strings = tf.strings.as_string(strings)
features = {"float_col": floats, "int_col": ints, "string_col": strings}
Reported by Pylint.
Line: 47
Column: 1
ints = ints * 1000
# Use a fixed vocabulary of strings from 0 to 99, to showcase loading a
# vocabulary from a file.
strings = tf.random.uniform((DS_SIZE, 1), maxval=VOCAB_SIZE, dtype="int64")
strings = tf.strings.as_string(strings)
features = {"float_col": floats, "int_col": ints, "string_col": strings}
# Random binary label.
labels = tf.random.uniform((DS_SIZE, 1), maxval=2, dtype="int64")
ds = tf.data.Dataset.from_tensor_slices((features, labels))
Reported by Pylint.
Line: 48
Column: 1
# Use a fixed vocabulary of strings from 0 to 99, to showcase loading a
# vocabulary from a file.
strings = tf.random.uniform((DS_SIZE, 1), maxval=VOCAB_SIZE, dtype="int64")
strings = tf.strings.as_string(strings)
features = {"float_col": floats, "int_col": ints, "string_col": strings}
# Random binary label.
labels = tf.random.uniform((DS_SIZE, 1), maxval=2, dtype="int64")
ds = tf.data.Dataset.from_tensor_slices((features, labels))
return ds
Reported by Pylint.
Line: 49
Column: 1
# vocabulary from a file.
strings = tf.random.uniform((DS_SIZE, 1), maxval=VOCAB_SIZE, dtype="int64")
strings = tf.strings.as_string(strings)
features = {"float_col": floats, "int_col": ints, "string_col": strings}
# Random binary label.
labels = tf.random.uniform((DS_SIZE, 1), maxval=2, dtype="int64")
ds = tf.data.Dataset.from_tensor_slices((features, labels))
return ds
Reported by Pylint.
Line: 51
Column: 1
strings = tf.strings.as_string(strings)
features = {"float_col": floats, "int_col": ints, "string_col": strings}
# Random binary label.
labels = tf.random.uniform((DS_SIZE, 1), maxval=2, dtype="int64")
ds = tf.data.Dataset.from_tensor_slices((features, labels))
return ds
def make_preprocessing_model(file_dir):
Reported by Pylint.