The following issues were found
keras/utils/losses_utils.py
132 issues
Line: 18
Column: 1
# pylint: disable=protected-access
"""Utilities related to loss functions."""
import tensorflow.compat.v2 as tf
from keras import backend
from keras.engine import keras_tensor
from tensorflow.python.util.tf_export import keras_export
Reported by Pylint.
Line: 21
Column: 1
import tensorflow.compat.v2 as tf
from keras import backend
from keras.engine import keras_tensor
from tensorflow.python.util.tf_export import keras_export
@keras_export('keras.losses.Reduction', v1=[])
class ReductionV2:
"""Types of loss reduction.
Reported by Pylint.
Line: 192
Column: 1
else:
# Use dynamic rank.
rank_diff = tf.rank(y_pred) - tf.rank(y_true)
squeeze_dims = lambda: remove_squeezable_dimensions( # pylint: disable=g-long-lambda
y_true, y_pred)
is_last_dim_1 = tf.equal(1, tf.shape(y_pred)[-1])
maybe_squeeze_dims = lambda: tf.cond( # pylint: disable=g-long-lambda
is_last_dim_1, squeeze_dims, lambda: (y_true, y_pred))
y_true, y_pred = tf.cond(
Reported by Pylint.
Line: 195
Column: 1
squeeze_dims = lambda: remove_squeezable_dimensions( # pylint: disable=g-long-lambda
y_true, y_pred)
is_last_dim_1 = tf.equal(1, tf.shape(y_pred)[-1])
maybe_squeeze_dims = lambda: tf.cond( # pylint: disable=g-long-lambda
is_last_dim_1, squeeze_dims, lambda: (y_true, y_pred))
y_true, y_pred = tf.cond(
tf.equal(1, rank_diff), maybe_squeeze_dims, squeeze_dims)
if sample_weight is None:
Reported by Pylint.
Line: 316
Column: 3
(keras_tensor.KerasTensor, tf.RaggedTensor)):
sample_weight = tf.convert_to_tensor(sample_weight)
# TODO(psv): Handle casting here in a better way, eg. if losses is float64
# we do not want to lose precision.
losses = tf.cast(losses, 'float32')
sample_weight = tf.cast(sample_weight, 'float32')
# Update dimensions of `sample_weight` to match with `losses` if possible.
losses, _, sample_weight = squeeze_or_expand_dimensions( # pylint: disable=unbalanced-tuple-unpacking
Reported by Pylint.
Line: 26
Column: 1
@keras_export('keras.losses.Reduction', v1=[])
class ReductionV2:
"""Types of loss reduction.
Contains the following values:
* `AUTO`: Indicates that the reduction option will be determined by the usage
context. For almost all cases this defaults to `SUM_OVER_BATCH_SIZE`. When
Reported by Pylint.
Line: 71
Column: 1
details on this.
"""
AUTO = 'auto'
NONE = 'none'
SUM = 'sum'
SUM_OVER_BATCH_SIZE = 'sum_over_batch_size'
@classmethod
Reported by Pylint.
Line: 72
Column: 1
"""
AUTO = 'auto'
NONE = 'none'
SUM = 'sum'
SUM_OVER_BATCH_SIZE = 'sum_over_batch_size'
@classmethod
def all(cls):
Reported by Pylint.
Line: 73
Column: 1
AUTO = 'auto'
NONE = 'none'
SUM = 'sum'
SUM_OVER_BATCH_SIZE = 'sum_over_batch_size'
@classmethod
def all(cls):
return (cls.AUTO, cls.NONE, cls.SUM, cls.SUM_OVER_BATCH_SIZE)
Reported by Pylint.
Line: 74
Column: 1
AUTO = 'auto'
NONE = 'none'
SUM = 'sum'
SUM_OVER_BATCH_SIZE = 'sum_over_batch_size'
@classmethod
def all(cls):
return (cls.AUTO, cls.NONE, cls.SUM, cls.SUM_OVER_BATCH_SIZE)
Reported by Pylint.
keras/applications/mobilenet.py
131 issues
Line: 64
Column: 1
https://arxiv.org/abs/1704.04861)
"""
import tensorflow.compat.v2 as tf
from keras import backend
from keras.applications import imagenet_utils
from keras.engine import training
from keras.layers import VersionAwareLayers
Reported by Pylint.
Line: 72
Column: 1
from keras.layers import VersionAwareLayers
from keras.utils import data_utils
from keras.utils import layer_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export
BASE_WEIGHT_PATH = ('https://storage.googleapis.com/tensorflow/'
'keras-applications/mobilenet/')
layers = None
Reported by Pylint.
Line: 73
Column: 1
from keras.utils import data_utils
from keras.utils import layer_utils
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export
BASE_WEIGHT_PATH = ('https://storage.googleapis.com/tensorflow/'
'keras-applications/mobilenet/')
layers = None
Reported by Pylint.
Line: 162
Column: 3
Returns:
A `keras.Model` instance.
"""
global layers
if 'layers' in kwargs:
layers = kwargs.pop('layers')
else:
layers = VersionAwareLayers()
if kwargs:
Reported by Pylint.
Line: 82
Column: 1
@keras_export('keras.applications.mobilenet.MobileNet',
'keras.applications.MobileNet')
def MobileNet(input_shape=None,
alpha=1.0,
depth_multiplier=1,
dropout=1e-3,
include_top=True,
weights='imagenet',
Reported by Pylint.
Line: 82
Column: 1
@keras_export('keras.applications.mobilenet.MobileNet',
'keras.applications.MobileNet')
def MobileNet(input_shape=None,
alpha=1.0,
depth_multiplier=1,
dropout=1e-3,
include_top=True,
weights='imagenet',
Reported by Pylint.
Line: 82
Column: 1
@keras_export('keras.applications.mobilenet.MobileNet',
'keras.applications.MobileNet')
def MobileNet(input_shape=None,
alpha=1.0,
depth_multiplier=1,
dropout=1e-3,
include_top=True,
weights='imagenet',
Reported by Pylint.
Line: 82
Column: 1
@keras_export('keras.applications.mobilenet.MobileNet',
'keras.applications.MobileNet')
def MobileNet(input_shape=None,
alpha=1.0,
depth_multiplier=1,
dropout=1e-3,
include_top=True,
weights='imagenet',
Reported by Pylint.
Line: 93
Column: 1
classes=1000,
classifier_activation='softmax',
**kwargs):
"""Instantiates the MobileNet architecture.
Reference:
- [MobileNets: Efficient Convolutional Neural Networks
for Mobile Vision Applications](
https://arxiv.org/abs/1704.04861)
Reported by Pylint.
Line: 162
Column: 1
Returns:
A `keras.Model` instance.
"""
global layers
if 'layers' in kwargs:
layers = kwargs.pop('layers')
else:
layers = VersionAwareLayers()
if kwargs:
Reported by Pylint.
keras/tests/model_subclassing_test_util.py
131 issues
Line: 17
Column: 1
# ==============================================================================
"""Keras models for use in Model subclassing tests."""
import keras
from keras import testing_utils
# pylint: disable=missing-docstring,not-callable
class SimpleConvTestModel(keras.Model):
Reported by Pylint.
Line: 18
Column: 1
"""Keras models for use in Model subclassing tests."""
import keras
from keras import testing_utils
# pylint: disable=missing-docstring,not-callable
class SimpleConvTestModel(keras.Model):
Reported by Pylint.
Line: 139
Column: 58
self.dense1 = keras.layers.Dense(1, activation='relu')
self.dense2 = keras.layers.Dense(1, activation='softmax')
def call(self, first, second, fiddle_with_output='no', training=True):
combined = self.dense1(first) + self.dense2(second)
if fiddle_with_output == 'yes':
return 10. * combined
else:
return combined
Reported by Pylint.
Line: 153
Column: 21
super(TrainingNoDefaultModel, self).__init__()
self.dense1 = keras.layers.Dense(1)
def call(self, x, training):
return self.dense1(x)
class TrainingMaskingModel(keras.Model):
Reported by Pylint.
Line: 163
Column: 21
super(TrainingMaskingModel, self).__init__()
self.dense1 = keras.layers.Dense(1)
def call(self, x, training=False, mask=None):
return self.dense1(x)
Reported by Pylint.
Line: 163
Column: 37
super(TrainingMaskingModel, self).__init__()
self.dense1 = keras.layers.Dense(1)
def call(self, x, training=False, mask=None):
return self.dense1(x)
Reported by Pylint.
Line: 22
Column: 1
# pylint: disable=missing-docstring,not-callable
class SimpleConvTestModel(keras.Model):
def __init__(self, num_classes=10):
super(SimpleConvTestModel, self).__init__(name='test_model')
self.num_classes = num_classes
Reported by Pylint.
Line: 24
Column: 1
# pylint: disable=missing-docstring,not-callable
class SimpleConvTestModel(keras.Model):
def __init__(self, num_classes=10):
super(SimpleConvTestModel, self).__init__(name='test_model')
self.num_classes = num_classes
self.conv1 = keras.layers.Conv2D(32, (3, 3), activation='relu')
self.flatten = keras.layers.Flatten()
Reported by Pylint.
Line: 25
Column: 5
class SimpleConvTestModel(keras.Model):
def __init__(self, num_classes=10):
super(SimpleConvTestModel, self).__init__(name='test_model')
self.num_classes = num_classes
self.conv1 = keras.layers.Conv2D(32, (3, 3), activation='relu')
self.flatten = keras.layers.Flatten()
self.dense1 = keras.layers.Dense(num_classes, activation='softmax')
Reported by Pylint.
Line: 25
Column: 1
class SimpleConvTestModel(keras.Model):
def __init__(self, num_classes=10):
super(SimpleConvTestModel, self).__init__(name='test_model')
self.num_classes = num_classes
self.conv1 = keras.layers.Conv2D(32, (3, 3), activation='relu')
self.flatten = keras.layers.Flatten()
self.dense1 = keras.layers.Dense(num_classes, activation='softmax')
Reported by Pylint.
keras/utils/object_identity.py
131 issues
Line: 198
Column: 3
def __contains__(self, key):
return self._wrap_key(key) in self._storage
def discard(self, key):
self._storage.discard(self._wrap_key(key))
def add(self, key):
self._storage.add(self._wrap_key(key))
Reported by Pylint.
Line: 201
Column: 3
def discard(self, key):
self._storage.discard(self._wrap_key(key))
def add(self, key):
self._storage.add(self._wrap_key(key))
def update(self, items):
self._storage.update([self._wrap_key(item) for item in items])
Reported by Pylint.
Line: 23
Column: 1
# LINT.IfChange
class _ObjectIdentityWrapper:
"""Wraps an object, mapping __eq__ on wrapper to "is" on wrapped.
Since __eq__ is based on object identity, it's safe to also define __hash__
based on object ids. This lets us add unhashable types like trackable
_ListWrapper objects to object-identity collections.
"""
Reported by Pylint.
Line: 30
Column: 1
_ListWrapper objects to object-identity collections.
"""
__slots__ = ["_wrapped", "__weakref__"]
def __init__(self, wrapped):
self._wrapped = wrapped
@property
Reported by Pylint.
Line: 32
Column: 1
__slots__ = ["_wrapped", "__weakref__"]
def __init__(self, wrapped):
self._wrapped = wrapped
@property
def unwrapped(self):
return self._wrapped
Reported by Pylint.
Line: 33
Column: 1
__slots__ = ["_wrapped", "__weakref__"]
def __init__(self, wrapped):
self._wrapped = wrapped
@property
def unwrapped(self):
return self._wrapped
Reported by Pylint.
Line: 35
Column: 1
def __init__(self, wrapped):
self._wrapped = wrapped
@property
def unwrapped(self):
return self._wrapped
def _assert_type(self, other):
if not isinstance(other, _ObjectIdentityWrapper):
Reported by Pylint.
Line: 36
Column: 3
self._wrapped = wrapped
@property
def unwrapped(self):
return self._wrapped
def _assert_type(self, other):
if not isinstance(other, _ObjectIdentityWrapper):
raise TypeError(
Reported by Pylint.
Line: 36
Column: 1
self._wrapped = wrapped
@property
def unwrapped(self):
return self._wrapped
def _assert_type(self, other):
if not isinstance(other, _ObjectIdentityWrapper):
raise TypeError(
Reported by Pylint.
Line: 37
Column: 1
@property
def unwrapped(self):
return self._wrapped
def _assert_type(self, other):
if not isinstance(other, _ObjectIdentityWrapper):
raise TypeError(
"Cannot compare wrapped object with unwrapped object. "
Reported by Pylint.
keras/distribute/sidecar_evaluator_test.py
129 issues
Line: 18
Column: 1
# ==============================================================================
"""Test covering sidecar_evaluator.py."""
import tensorflow.compat.v2 as tf
import enum
import os
from absl import logging
Reported by Pylint.
Line: 23
Column: 1
import enum
import os
from absl import logging
from absl.testing import parameterized
import numpy as np
import keras
from keras.distribute import sidecar_evaluator as sidecar_evaluator_lib
Reported by Pylint.
Line: 24
Column: 1
import os
from absl import logging
from absl.testing import parameterized
import numpy as np
import keras
from keras.distribute import sidecar_evaluator as sidecar_evaluator_lib
from keras.optimizer_v2 import gradient_descent
Reported by Pylint.
Line: 34
Column: 1
_BATCH_SIZE = 32
class TestModel(keras.Model):
def __init__(self):
super().__init__(name='test_model')
self.dense = keras.layers.Dense(10)
Reported by Pylint.
Line: 40
Column: 3
super().__init__(name='test_model')
self.dense = keras.layers.Dense(10)
def call(self, inputs):
return self.dense(inputs)
class DictMetric(keras.metrics.MeanSquaredError):
Reported by Pylint.
Line: 253
Column: 22
self.assertModelsSameVariables(model, eval_model)
# check the iterations is restored.
self.assertEqual(sidecar_evaluator._iterations.numpy(), _BATCH_SIZE)
self.assertSummaryEventsWritten(os.path.join(log_dir, 'validation'))
if __name__ == '__main__':
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
import enum
import os
from absl import logging
from absl.testing import parameterized
import numpy as np
Reported by Pylint.
Line: 21
Column: 1
import tensorflow.compat.v2 as tf
import enum
import os
from absl import logging
from absl.testing import parameterized
import numpy as np
Reported by Pylint.
Line: 34
Column: 1
_BATCH_SIZE = 32
class TestModel(keras.Model):
def __init__(self):
super().__init__(name='test_model')
self.dense = keras.layers.Dense(10)
Reported by Pylint.
Line: 36
Column: 1
class TestModel(keras.Model):
def __init__(self):
super().__init__(name='test_model')
self.dense = keras.layers.Dense(10)
def call(self, inputs):
return self.dense(inputs)
Reported by Pylint.
keras/engine/input_spec.py
128 issues
Line: 16
Column: 1
# limitations under the License.
# ==============================================================================
# pylint: disable=protected-access
# pylint: disable=g-classes-have-attributes
"""Contains the InputSpec class."""
import tensorflow.compat.v2 as tf
from keras import backend
from tensorflow.python.util.tf_export import keras_export
Reported by Pylint.
Line: 19
Column: 1
# pylint: disable=g-classes-have-attributes
"""Contains the InputSpec class."""
import tensorflow.compat.v2 as tf
from keras import backend
from tensorflow.python.util.tf_export import keras_export
from tensorflow.python.util.tf_export import tf_export
Reported by Pylint.
Line: 21
Column: 1
import tensorflow.compat.v2 as tf
from keras import backend
from tensorflow.python.util.tf_export import keras_export
from tensorflow.python.util.tf_export import tf_export
@keras_export('keras.layers.InputSpec',
v1=['keras.layers.InputSpec',
Reported by Pylint.
Line: 22
Column: 1
import tensorflow.compat.v2 as tf
from keras import backend
from tensorflow.python.util.tf_export import keras_export
from tensorflow.python.util.tf_export import tf_export
@keras_export('keras.layers.InputSpec',
v1=['keras.layers.InputSpec',
'keras.__internal__.legacy.layers.InputSpec'])
Reported by Pylint.
Line: 99
Column: 7
axes = axes or {}
self.axes = {int(k): axes[k] for k in axes}
except (ValueError, TypeError):
raise TypeError('The keys in axes must be integers.')
if self.axes and (self.ndim is not None or self.max_ndim is not None):
max_dim = (self.ndim if self.ndim else self.max_ndim) - 1
max_axis = max(self.axes)
if max_axis > max_dim:
Reported by Pylint.
Line: 29
Column: 1
v1=['keras.layers.InputSpec',
'keras.__internal__.legacy.layers.InputSpec'])
@tf_export(v1=['layers.InputSpec'])
class InputSpec:
"""Specifies the rank, dtype and shape of every input to a layer.
Layers can expose (if appropriate) an `input_spec` attribute:
an instance of `InputSpec`, or a nested structure of `InputSpec` instances
(one per input tensor). These objects enable the layer to run input
Reported by Pylint.
Line: 30
Column: 1
'keras.__internal__.legacy.layers.InputSpec'])
@tf_export(v1=['layers.InputSpec'])
class InputSpec:
"""Specifies the rank, dtype and shape of every input to a layer.
Layers can expose (if appropriate) an `input_spec` attribute:
an instance of `InputSpec`, or a nested structure of `InputSpec` instances
(one per input tensor). These objects enable the layer to run input
compatibility checks for input structure, input rank, input shape, and
Reported by Pylint.
Line: 70
Column: 1
```
"""
def __init__(self,
dtype=None,
shape=None,
ndim=None,
max_ndim=None,
min_ndim=None,
Reported by Pylint.
Line: 70
Column: 3
```
"""
def __init__(self,
dtype=None,
shape=None,
ndim=None,
max_ndim=None,
min_ndim=None,
Reported by Pylint.
Line: 79
Column: 1
axes=None,
allow_last_axis_squeeze=False,
name=None):
self.dtype = tf.as_dtype(dtype).name if dtype is not None else None
shape = tf.TensorShape(shape)
if shape.rank is None:
shape = None
else:
shape = tuple(shape.as_list())
Reported by Pylint.
keras/engine/node_test.py
126 issues
Line: 17
Column: 1
#,============================================================================
"""Tests for layer graphs construction & handling."""
import tensorflow.compat.v2 as tf
from keras import keras_parameterized
from keras.engine import base_layer
from keras.engine import node as node_module
Reported by Pylint.
Line: 95
Column: 57
node_module.Node(layer=concat_layer, call_args=([a_2, b_2],),
outputs=merged)
merge_layer, merge_node_index, merge_tensor_index = merged._keras_history
self.assertEqual(merge_node_index, 0)
self.assertEqual(merge_tensor_index, 0)
self.assertLen(merge_layer._inbound_nodes, 1)
Reported by Pylint.
Line: 130
Column: 57
call_kwargs={'x': kwarg_x, 'y': kwarg_y},
outputs=merged)
merge_layer, merge_node_index, merge_tensor_index = merged._keras_history
# Check the saved call args/kwargs
self.assertEqual(([a, b], arg_2, arg_3), node.call_args)
self.assertEqual({'x': kwarg_x, 'y': kwarg_y}, node.call_kwargs)
Reported by Pylint.
Line: 69
Column: 20
self.assertEqual(node_a.outputs, a_2)
# Test the layer wiring
self.assertLen(dense._inbound_nodes, 2)
self.assertLen(dense._outbound_nodes, 0)
self.assertEqual(dense._inbound_nodes, [node_a, node_b])
self.assertEqual(dense._inbound_nodes[0].inbound_layers, a_layer)
self.assertEqual(dense._inbound_nodes[0].outbound_layer, dense)
self.assertEqual(dense._inbound_nodes[1].inbound_layers, b_layer)
Reported by Pylint.
Line: 70
Column: 20
# Test the layer wiring
self.assertLen(dense._inbound_nodes, 2)
self.assertLen(dense._outbound_nodes, 0)
self.assertEqual(dense._inbound_nodes, [node_a, node_b])
self.assertEqual(dense._inbound_nodes[0].inbound_layers, a_layer)
self.assertEqual(dense._inbound_nodes[0].outbound_layer, dense)
self.assertEqual(dense._inbound_nodes[1].inbound_layers, b_layer)
self.assertEqual(dense._inbound_nodes[1].outbound_layer, dense)
Reported by Pylint.
Line: 71
Column: 22
# Test the layer wiring
self.assertLen(dense._inbound_nodes, 2)
self.assertLen(dense._outbound_nodes, 0)
self.assertEqual(dense._inbound_nodes, [node_a, node_b])
self.assertEqual(dense._inbound_nodes[0].inbound_layers, a_layer)
self.assertEqual(dense._inbound_nodes[0].outbound_layer, dense)
self.assertEqual(dense._inbound_nodes[1].inbound_layers, b_layer)
self.assertEqual(dense._inbound_nodes[1].outbound_layer, dense)
self.assertIs(dense._inbound_nodes[0].input_tensors, a)
Reported by Pylint.
Line: 72
Column: 22
self.assertLen(dense._inbound_nodes, 2)
self.assertLen(dense._outbound_nodes, 0)
self.assertEqual(dense._inbound_nodes, [node_a, node_b])
self.assertEqual(dense._inbound_nodes[0].inbound_layers, a_layer)
self.assertEqual(dense._inbound_nodes[0].outbound_layer, dense)
self.assertEqual(dense._inbound_nodes[1].inbound_layers, b_layer)
self.assertEqual(dense._inbound_nodes[1].outbound_layer, dense)
self.assertIs(dense._inbound_nodes[0].input_tensors, a)
self.assertIs(dense._inbound_nodes[1].input_tensors, b)
Reported by Pylint.
Line: 73
Column: 22
self.assertLen(dense._outbound_nodes, 0)
self.assertEqual(dense._inbound_nodes, [node_a, node_b])
self.assertEqual(dense._inbound_nodes[0].inbound_layers, a_layer)
self.assertEqual(dense._inbound_nodes[0].outbound_layer, dense)
self.assertEqual(dense._inbound_nodes[1].inbound_layers, b_layer)
self.assertEqual(dense._inbound_nodes[1].outbound_layer, dense)
self.assertIs(dense._inbound_nodes[0].input_tensors, a)
self.assertIs(dense._inbound_nodes[1].input_tensors, b)
Reported by Pylint.
Line: 74
Column: 22
self.assertEqual(dense._inbound_nodes, [node_a, node_b])
self.assertEqual(dense._inbound_nodes[0].inbound_layers, a_layer)
self.assertEqual(dense._inbound_nodes[0].outbound_layer, dense)
self.assertEqual(dense._inbound_nodes[1].inbound_layers, b_layer)
self.assertEqual(dense._inbound_nodes[1].outbound_layer, dense)
self.assertIs(dense._inbound_nodes[0].input_tensors, a)
self.assertIs(dense._inbound_nodes[1].input_tensors, b)
def test_multi_input_node(self):
Reported by Pylint.
Line: 75
Column: 22
self.assertEqual(dense._inbound_nodes[0].inbound_layers, a_layer)
self.assertEqual(dense._inbound_nodes[0].outbound_layer, dense)
self.assertEqual(dense._inbound_nodes[1].inbound_layers, b_layer)
self.assertEqual(dense._inbound_nodes[1].outbound_layer, dense)
self.assertIs(dense._inbound_nodes[0].input_tensors, a)
self.assertIs(dense._inbound_nodes[1].input_tensors, b)
def test_multi_input_node(self):
# test multi-input layer
Reported by Pylint.
keras/distribute/saved_model_test_base.py
125 issues
Line: 17
Column: 1
# ==============================================================================
"""Base class for testing saving/loading with DS."""
import tensorflow.compat.v2 as tf
import os
from absl.testing import parameterized
import numpy as np
Reported by Pylint.
Line: 21
Column: 1
import os
from absl.testing import parameterized
import numpy as np
from keras import backend
from keras.distribute import model_combinations
_RANDOM_SEED = 1337
Reported by Pylint.
Line: 166
Column: 33
# Train the model for 1 epoch
model.fit(x=training_dataset, epochs=1, steps_per_epoch=100)
def _predict_with_model(self, distribution, model, predict_dataset):
return model.predict(predict_dataset, steps=PREDICT_STEPS)
def _get_predict_dataset(self, x_predict, batch_size):
predict_dataset = tf.data.Dataset.from_tensor_slices(x_predict)
predict_dataset = predict_dataset.repeat()
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
import os
from absl.testing import parameterized
import numpy as np
from keras import backend
from keras.distribute import model_combinations
Reported by Pylint.
Line: 57
Column: 1
]
def get_tolerance(save_distribution, restore_distribution):
if backend.is_tpu_strategy(save_distribution) or backend.is_tpu_strategy(
restore_distribution):
return _TPU_TOLERANCE
return _TOLERANCE
Reported by Pylint.
Line: 58
Column: 1
def get_tolerance(save_distribution, restore_distribution):
if backend.is_tpu_strategy(save_distribution) or backend.is_tpu_strategy(
restore_distribution):
return _TPU_TOLERANCE
return _TOLERANCE
Reported by Pylint.
Line: 60
Column: 1
def get_tolerance(save_distribution, restore_distribution):
if backend.is_tpu_strategy(save_distribution) or backend.is_tpu_strategy(
restore_distribution):
return _TPU_TOLERANCE
return _TOLERANCE
def simple_models_with_strategies():
return tf.__internal__.test.combinations.combine(
Reported by Pylint.
Line: 61
Column: 1
if backend.is_tpu_strategy(save_distribution) or backend.is_tpu_strategy(
restore_distribution):
return _TPU_TOLERANCE
return _TOLERANCE
def simple_models_with_strategies():
return tf.__internal__.test.combinations.combine(
model_and_input=simple_models,
Reported by Pylint.
Line: 64
Column: 1
return _TOLERANCE
def simple_models_with_strategies():
return tf.__internal__.test.combinations.combine(
model_and_input=simple_models,
distribution=strategies,
mode=['eager'])
Reported by Pylint.
Line: 65
Column: 1
def simple_models_with_strategies():
return tf.__internal__.test.combinations.combine(
model_and_input=simple_models,
distribution=strategies,
mode=['eager'])
Reported by Pylint.
keras/wrappers/scikit_learn_test.py
125 issues
Line: 19
Column: 1
import warnings
import tensorflow.compat.v2 as tf
import numpy as np
import keras
from keras import testing_utils
Reported by Pylint.
Line: 36
Column: 1
EPOCHS = 1
def build_fn_clf(hidden_dim):
model = keras.models.Sequential()
model.add(keras.layers.Dense(INPUT_DIM, input_shape=(INPUT_DIM,)))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(hidden_dim))
model.add(keras.layers.Activation('relu'))
Reported by Pylint.
Line: 37
Column: 1
def build_fn_clf(hidden_dim):
model = keras.models.Sequential()
model.add(keras.layers.Dense(INPUT_DIM, input_shape=(INPUT_DIM,)))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(hidden_dim))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(NUM_CLASSES))
Reported by Pylint.
Line: 38
Column: 1
def build_fn_clf(hidden_dim):
model = keras.models.Sequential()
model.add(keras.layers.Dense(INPUT_DIM, input_shape=(INPUT_DIM,)))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(hidden_dim))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(NUM_CLASSES))
model.add(keras.layers.Activation('softmax'))
Reported by Pylint.
Line: 39
Column: 1
def build_fn_clf(hidden_dim):
model = keras.models.Sequential()
model.add(keras.layers.Dense(INPUT_DIM, input_shape=(INPUT_DIM,)))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(hidden_dim))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(NUM_CLASSES))
model.add(keras.layers.Activation('softmax'))
model.compile(
Reported by Pylint.
Line: 40
Column: 1
model = keras.models.Sequential()
model.add(keras.layers.Dense(INPUT_DIM, input_shape=(INPUT_DIM,)))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(hidden_dim))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(NUM_CLASSES))
model.add(keras.layers.Activation('softmax'))
model.compile(
optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])
Reported by Pylint.
Line: 41
Column: 1
model.add(keras.layers.Dense(INPUT_DIM, input_shape=(INPUT_DIM,)))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(hidden_dim))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(NUM_CLASSES))
model.add(keras.layers.Activation('softmax'))
model.compile(
optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])
return model
Reported by Pylint.
Line: 42
Column: 1
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(hidden_dim))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(NUM_CLASSES))
model.add(keras.layers.Activation('softmax'))
model.compile(
optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])
return model
Reported by Pylint.
Line: 43
Column: 1
model.add(keras.layers.Dense(hidden_dim))
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(NUM_CLASSES))
model.add(keras.layers.Activation('softmax'))
model.compile(
optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])
return model
Reported by Pylint.
Line: 44
Column: 1
model.add(keras.layers.Activation('relu'))
model.add(keras.layers.Dense(NUM_CLASSES))
model.add(keras.layers.Activation('softmax'))
model.compile(
optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])
return model
def assert_classification_works(clf):
Reported by Pylint.
keras/utils/vis_utils_test.py
124 issues
Line: 17
Column: 1
# ==============================================================================
"""Tests for Keras Vis utils."""
import tensorflow.compat.v2 as tf
from absl.testing import parameterized
import keras
from keras.applications import efficientnet
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
from absl.testing import parameterized
import keras
from keras.applications import efficientnet
from keras.utils import vis_utils
Reported by Pylint.
Line: 26
Column: 1
from keras.utils import vis_utils
class ModelToDotFormatTest(tf.test.TestCase, parameterized.TestCase):
def test_plot_model_cnn(self):
model = keras.Sequential()
model.add(
keras.layers.Conv2D(
Reported by Pylint.
Line: 28
Column: 1
class ModelToDotFormatTest(tf.test.TestCase, parameterized.TestCase):
def test_plot_model_cnn(self):
model = keras.Sequential()
model.add(
keras.layers.Conv2D(
filters=2, kernel_size=(2, 3), input_shape=(3, 5, 5), name='conv'))
model.add(keras.layers.Flatten(name='flat'))
Reported by Pylint.
Line: 28
Column: 3
class ModelToDotFormatTest(tf.test.TestCase, parameterized.TestCase):
def test_plot_model_cnn(self):
model = keras.Sequential()
model.add(
keras.layers.Conv2D(
filters=2, kernel_size=(2, 3), input_shape=(3, 5, 5), name='conv'))
model.add(keras.layers.Flatten(name='flat'))
Reported by Pylint.
Line: 29
Column: 1
class ModelToDotFormatTest(tf.test.TestCase, parameterized.TestCase):
def test_plot_model_cnn(self):
model = keras.Sequential()
model.add(
keras.layers.Conv2D(
filters=2, kernel_size=(2, 3), input_shape=(3, 5, 5), name='conv'))
model.add(keras.layers.Flatten(name='flat'))
model.add(keras.layers.Dense(5, name='dense'))
Reported by Pylint.
Line: 30
Column: 1
def test_plot_model_cnn(self):
model = keras.Sequential()
model.add(
keras.layers.Conv2D(
filters=2, kernel_size=(2, 3), input_shape=(3, 5, 5), name='conv'))
model.add(keras.layers.Flatten(name='flat'))
model.add(keras.layers.Dense(5, name='dense'))
dot_img_file = 'model_1.png'
Reported by Pylint.
Line: 33
Column: 1
model.add(
keras.layers.Conv2D(
filters=2, kernel_size=(2, 3), input_shape=(3, 5, 5), name='conv'))
model.add(keras.layers.Flatten(name='flat'))
model.add(keras.layers.Dense(5, name='dense'))
dot_img_file = 'model_1.png'
try:
vis_utils.plot_model(
model, to_file=dot_img_file, show_shapes=True, show_dtype=True)
Reported by Pylint.
Line: 34
Column: 1
keras.layers.Conv2D(
filters=2, kernel_size=(2, 3), input_shape=(3, 5, 5), name='conv'))
model.add(keras.layers.Flatten(name='flat'))
model.add(keras.layers.Dense(5, name='dense'))
dot_img_file = 'model_1.png'
try:
vis_utils.plot_model(
model, to_file=dot_img_file, show_shapes=True, show_dtype=True)
self.assertTrue(tf.io.gfile.exists(dot_img_file))
Reported by Pylint.
Line: 35
Column: 1
filters=2, kernel_size=(2, 3), input_shape=(3, 5, 5), name='conv'))
model.add(keras.layers.Flatten(name='flat'))
model.add(keras.layers.Dense(5, name='dense'))
dot_img_file = 'model_1.png'
try:
vis_utils.plot_model(
model, to_file=dot_img_file, show_shapes=True, show_dtype=True)
self.assertTrue(tf.io.gfile.exists(dot_img_file))
tf.io.gfile.remove(dot_img_file)
Reported by Pylint.