The following issues were found
keras/engine/input_spec_test.py
32 issues
Line: 21
Column: 1
from __future__ import division
from __future__ import print_function
import tensorflow.compat.v2 as tf
from keras.engine import input_spec
class InputSpecTest(tf.test.TestCase):
Reported by Pylint.
Line: 26
Column: 1
from keras.engine import input_spec
class InputSpecTest(tf.test.TestCase):
def test_axes_initialization(self):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={3: 5, '2': 2})
with self.assertRaisesRegex(ValueError, 'Axis 4 is greater than'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={4: 5})
Reported by Pylint.
Line: 26
Column: 1
from keras.engine import input_spec
class InputSpecTest(tf.test.TestCase):
def test_axes_initialization(self):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={3: 5, '2': 2})
with self.assertRaisesRegex(ValueError, 'Axis 4 is greater than'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={4: 5})
Reported by Pylint.
Line: 28
Column: 1
class InputSpecTest(tf.test.TestCase):
def test_axes_initialization(self):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={3: 5, '2': 2})
with self.assertRaisesRegex(ValueError, 'Axis 4 is greater than'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={4: 5})
with self.assertRaisesRegex(TypeError, 'keys in axes must be integers'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={'string': 5})
Reported by Pylint.
Line: 28
Column: 3
class InputSpecTest(tf.test.TestCase):
def test_axes_initialization(self):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={3: 5, '2': 2})
with self.assertRaisesRegex(ValueError, 'Axis 4 is greater than'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={4: 5})
with self.assertRaisesRegex(TypeError, 'keys in axes must be integers'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={'string': 5})
Reported by Pylint.
Line: 29
Column: 1
class InputSpecTest(tf.test.TestCase):
def test_axes_initialization(self):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={3: 5, '2': 2})
with self.assertRaisesRegex(ValueError, 'Axis 4 is greater than'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={4: 5})
with self.assertRaisesRegex(TypeError, 'keys in axes must be integers'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={'string': 5})
Reported by Pylint.
Line: 30
Column: 1
def test_axes_initialization(self):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={3: 5, '2': 2})
with self.assertRaisesRegex(ValueError, 'Axis 4 is greater than'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={4: 5})
with self.assertRaisesRegex(TypeError, 'keys in axes must be integers'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={'string': 5})
Reported by Pylint.
Line: 31
Column: 1
def test_axes_initialization(self):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={3: 5, '2': 2})
with self.assertRaisesRegex(ValueError, 'Axis 4 is greater than'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={4: 5})
with self.assertRaisesRegex(TypeError, 'keys in axes must be integers'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={'string': 5})
class InputSpecToTensorShapeTest(tf.test.TestCase):
Reported by Pylint.
Line: 32
Column: 1
input_spec.InputSpec(shape=[1, None, 2, 3], axes={3: 5, '2': 2})
with self.assertRaisesRegex(ValueError, 'Axis 4 is greater than'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={4: 5})
with self.assertRaisesRegex(TypeError, 'keys in axes must be integers'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={'string': 5})
class InputSpecToTensorShapeTest(tf.test.TestCase):
Reported by Pylint.
Line: 33
Column: 1
with self.assertRaisesRegex(ValueError, 'Axis 4 is greater than'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={4: 5})
with self.assertRaisesRegex(TypeError, 'keys in axes must be integers'):
input_spec.InputSpec(shape=[1, None, 2, 3], axes={'string': 5})
class InputSpecToTensorShapeTest(tf.test.TestCase):
def test_defined_shape(self):
Reported by Pylint.
keras/layers/preprocessing/benchmarks/category_hash_varlen_benchmark.py
31 issues
Line: 17
Column: 1
# ==============================================================================
"""Benchmark for KPL implementation of categorical hash columns with varying-length inputs."""
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
Reported by Pylint.
Line: 19
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
Reported by Pylint.
Line: 20
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 21
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 22
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
NUM_REPEATS = 10
Reported by Pylint.
Line: 32
Column: 1
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
num_buckets = 10000
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
Reported by Pylint.
Line: 35
Column: 1
"""Benchmark a variable-length embedding."""
# Data and constants.
num_buckets = 10000
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
# Keras implementation
Reported by Pylint.
Line: 36
Column: 1
# Data and constants.
num_buckets = 10000
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
# Keras implementation
model = keras.Sequential()
Reported by Pylint.
Line: 37
Column: 1
num_buckets = 10000
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
# Keras implementation
model = keras.Sequential()
model.add(
Reported by Pylint.
Line: 41
Column: 1
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
# Keras implementation
model = keras.Sequential()
model.add(
keras.Input(
shape=(max_length,), name="data", ragged=True, dtype=tf.string))
model.add(hashing.Hashing(num_buckets))
Reported by Pylint.
keras/layers/preprocessing/benchmarks/bucketized_column_dense_benchmark.py
31 issues
Line: 17
Column: 1
# ==============================================================================
"""Benchmark for KPL implementation of bucketized columns with dense inputs."""
import tensorflow as tf
import numpy as np
import keras
from tensorflow.python.eager.def_function import function as tf_function
Reported by Pylint.
Line: 21
Column: 1
import numpy as np
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import discretization
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
Reported by Pylint.
Line: 22
Column: 1
import numpy as np
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import discretization
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 23
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import discretization
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 24
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import discretization
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
NUM_REPEATS = 10 # The number of times to run each benchmark.
Reported by Pylint.
Line: 35
Column: 1
### KPL AND FC IMPLEMENTATION BENCHMARKS ###
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
max_value = 25.0
bins = np.arange(1.0, max_value)
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, 100000, dtype=float)
Reported by Pylint.
Line: 37
Column: 1
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
max_value = 25.0
bins = np.arange(1.0, max_value)
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, 100000, dtype=float)
# Keras implementation
Reported by Pylint.
Line: 38
Column: 1
"""Benchmark a variable-length embedding."""
# Data and constants.
max_value = 25.0
bins = np.arange(1.0, max_value)
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, 100000, dtype=float)
# Keras implementation
model = keras.Sequential()
Reported by Pylint.
Line: 39
Column: 1
# Data and constants.
max_value = 25.0
bins = np.arange(1.0, max_value)
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, 100000, dtype=float)
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(max_length,), name="data", dtype=tf.float32))
Reported by Pylint.
Line: 43
Column: 1
max_length, batch_size * NUM_REPEATS, 100000, dtype=float)
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(max_length,), name="data", dtype=tf.float32))
model.add(discretization.Discretization(bins))
# FC implementation
fc = tf.feature_column.bucketized_column(
Reported by Pylint.
keras/tests/get_config_test.py
31 issues
Line: 17
Column: 1
#,============================================================================
"""Tests for `get_config` backwards compatibility."""
import tensorflow.compat.v2 as tf
from keras import keras_parameterized
from keras.engine import sequential
from keras.engine import training
from keras.tests import get_config_samples
Reported by Pylint.
Line: 19
Column: 1
import tensorflow.compat.v2 as tf
from keras import keras_parameterized
from keras.engine import sequential
from keras.engine import training
from keras.tests import get_config_samples
Reported by Pylint.
Line: 20
Column: 1
import tensorflow.compat.v2 as tf
from keras import keras_parameterized
from keras.engine import sequential
from keras.engine import training
from keras.tests import get_config_samples
@keras_parameterized.run_all_keras_modes
Reported by Pylint.
Line: 21
Column: 1
from keras import keras_parameterized
from keras.engine import sequential
from keras.engine import training
from keras.tests import get_config_samples
@keras_parameterized.run_all_keras_modes
class TestGetConfigBackwardsCompatible(keras_parameterized.TestCase):
Reported by Pylint.
Line: 22
Column: 1
from keras import keras_parameterized
from keras.engine import sequential
from keras.engine import training
from keras.tests import get_config_samples
@keras_parameterized.run_all_keras_modes
class TestGetConfigBackwardsCompatible(keras_parameterized.TestCase):
Reported by Pylint.
Line: 26
Column: 1
@keras_parameterized.run_all_keras_modes
class TestGetConfigBackwardsCompatible(keras_parameterized.TestCase):
def test_functional_dnn(self):
model = training.Model.from_config(get_config_samples.FUNCTIONAL_DNN)
self.assertLen(model.layers, 3)
Reported by Pylint.
Line: 28
Column: 3
@keras_parameterized.run_all_keras_modes
class TestGetConfigBackwardsCompatible(keras_parameterized.TestCase):
def test_functional_dnn(self):
model = training.Model.from_config(get_config_samples.FUNCTIONAL_DNN)
self.assertLen(model.layers, 3)
def test_functional_cnn(self):
model = training.Model.from_config(get_config_samples.FUNCTIONAL_CNN)
Reported by Pylint.
Line: 28
Column: 1
@keras_parameterized.run_all_keras_modes
class TestGetConfigBackwardsCompatible(keras_parameterized.TestCase):
def test_functional_dnn(self):
model = training.Model.from_config(get_config_samples.FUNCTIONAL_DNN)
self.assertLen(model.layers, 3)
def test_functional_cnn(self):
model = training.Model.from_config(get_config_samples.FUNCTIONAL_CNN)
Reported by Pylint.
Line: 29
Column: 1
class TestGetConfigBackwardsCompatible(keras_parameterized.TestCase):
def test_functional_dnn(self):
model = training.Model.from_config(get_config_samples.FUNCTIONAL_DNN)
self.assertLen(model.layers, 3)
def test_functional_cnn(self):
model = training.Model.from_config(get_config_samples.FUNCTIONAL_CNN)
self.assertLen(model.layers, 4)
Reported by Pylint.
Line: 30
Column: 1
def test_functional_dnn(self):
model = training.Model.from_config(get_config_samples.FUNCTIONAL_DNN)
self.assertLen(model.layers, 3)
def test_functional_cnn(self):
model = training.Model.from_config(get_config_samples.FUNCTIONAL_CNN)
self.assertLen(model.layers, 4)
Reported by Pylint.
keras/layers/preprocessing/benchmarks/category_hash_dense_benchmark.py
31 issues
Line: 17
Column: 1
# ==============================================================================
"""Benchmark for KPL implementation of categorical hash columns with dense inputs."""
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
Reported by Pylint.
Line: 19
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
Reported by Pylint.
Line: 20
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 21
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 22
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import hashing
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
NUM_REPEATS = 10
Reported by Pylint.
Line: 32
Column: 1
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
num_buckets = 10000
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
Reported by Pylint.
Line: 35
Column: 1
"""Benchmark a variable-length embedding."""
# Data and constants.
num_buckets = 10000
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
# Keras implementation
Reported by Pylint.
Line: 36
Column: 1
# Data and constants.
num_buckets = 10000
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
# Keras implementation
model = keras.Sequential()
Reported by Pylint.
Line: 37
Column: 1
num_buckets = 10000
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(max_length,), name="data", dtype=tf.string))
Reported by Pylint.
Line: 41
Column: 1
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.0)
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(max_length,), name="data", dtype=tf.string))
model.add(hashing.Hashing(num_buckets))
# FC implementation
fc = tf.feature_column.sequence_categorical_column_with_hash_bucket("data", num_buckets)
Reported by Pylint.
keras/layers/preprocessing/normalization_distribution_test.py
30 issues
Line: 17
Column: 1
# ==============================================================================
"""Distribution tests for keras.layers.preprocessing.normalization."""
import tensorflow.compat.v2 as tf
import numpy as np
import keras
from keras import keras_parameterized
Reported by Pylint.
Line: 29
Column: 1
def _get_layer_computation_test_cases():
test_cases = ({
"adapt_data": np.array([[1.], [2.], [3.], [4.], [5.]], dtype=np.float32),
"axis": -1,
"test_data": np.array([[1.], [2.], [3.]], np.float32),
"expected": np.array([[-1.414214], [-.707107], [0]], np.float32),
"testcase_name": "2d_single_element"
Reported by Pylint.
Line: 80
Column: 1
"3d_multiple_axis"
})
crossed_test_cases = []
# Cross above test cases with use_dataset in (True, False)
for use_dataset in (True, False):
for case in test_cases:
case = case.copy()
if use_dataset:
Reported by Pylint.
Line: 82
Column: 1
crossed_test_cases = []
# Cross above test cases with use_dataset in (True, False)
for use_dataset in (True, False):
for case in test_cases:
case = case.copy()
if use_dataset:
case["testcase_name"] = case["testcase_name"] + "_with_dataset"
case["use_dataset"] = use_dataset
Reported by Pylint.
Line: 83
Column: 1
crossed_test_cases = []
# Cross above test cases with use_dataset in (True, False)
for use_dataset in (True, False):
for case in test_cases:
case = case.copy()
if use_dataset:
case["testcase_name"] = case["testcase_name"] + "_with_dataset"
case["use_dataset"] = use_dataset
crossed_test_cases.append(case)
Reported by Pylint.
Line: 84
Column: 1
# Cross above test cases with use_dataset in (True, False)
for use_dataset in (True, False):
for case in test_cases:
case = case.copy()
if use_dataset:
case["testcase_name"] = case["testcase_name"] + "_with_dataset"
case["use_dataset"] = use_dataset
crossed_test_cases.append(case)
Reported by Pylint.
Line: 85
Column: 1
for use_dataset in (True, False):
for case in test_cases:
case = case.copy()
if use_dataset:
case["testcase_name"] = case["testcase_name"] + "_with_dataset"
case["use_dataset"] = use_dataset
crossed_test_cases.append(case)
return crossed_test_cases
Reported by Pylint.
Line: 86
Column: 1
for case in test_cases:
case = case.copy()
if use_dataset:
case["testcase_name"] = case["testcase_name"] + "_with_dataset"
case["use_dataset"] = use_dataset
crossed_test_cases.append(case)
return crossed_test_cases
Reported by Pylint.
Line: 87
Column: 1
case = case.copy()
if use_dataset:
case["testcase_name"] = case["testcase_name"] + "_with_dataset"
case["use_dataset"] = use_dataset
crossed_test_cases.append(case)
return crossed_test_cases
Reported by Pylint.
Line: 88
Column: 1
if use_dataset:
case["testcase_name"] = case["testcase_name"] + "_with_dataset"
case["use_dataset"] = use_dataset
crossed_test_cases.append(case)
return crossed_test_cases
@tf.__internal__.distribute.combinations.generate(
Reported by Pylint.
keras/layers/preprocessing/benchmarks/category_vocab_list_dense_benchmark.py
30 issues
Line: 17
Column: 1
# ==============================================================================
"""Benchmark for KPL implementation of vocabulary columns from lists with dense inputs."""
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
Reported by Pylint.
Line: 19
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
Reported by Pylint.
Line: 20
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 21
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 22
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
NUM_REPEATS = 10
Reported by Pylint.
Line: 32
Column: 1
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)
Reported by Pylint.
Line: 34
Column: 1
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)
# Keras implementation
model = keras.Sequential()
Reported by Pylint.
Line: 35
Column: 1
"""Benchmark a variable-length embedding."""
# Data and constants.
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(max_length,), name="data", dtype=tf.string))
Reported by Pylint.
Line: 39
Column: 1
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(max_length,), name="data", dtype=tf.string))
model.add(string_lookup.StringLookup(vocabulary=vocab, mask_token=None))
# FC implementation
fc = tf.feature_column.categorical_column_with_vocabulary_list(
Reported by Pylint.
Line: 40
Column: 1
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(max_length,), name="data", dtype=tf.string))
model.add(string_lookup.StringLookup(vocabulary=vocab, mask_token=None))
# FC implementation
fc = tf.feature_column.categorical_column_with_vocabulary_list(
key="data", vocabulary_list=vocab, num_oov_buckets=1)
Reported by Pylint.
keras/layers/preprocessing/benchmarks/category_vocab_list_varlen_benchmark.py
30 issues
Line: 17
Column: 1
# ==============================================================================
"""Benchmark for KPL implementation of vocabulary columns from lists with varying-length inputs."""
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
Reported by Pylint.
Line: 19
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
Reported by Pylint.
Line: 20
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 21
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 22
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
NUM_REPEATS = 10
Reported by Pylint.
Line: 32
Column: 1
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)
Reported by Pylint.
Line: 34
Column: 1
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)
# Keras implementation
model = keras.Sequential()
Reported by Pylint.
Line: 35
Column: 1
"""Benchmark a variable-length embedding."""
# Data and constants.
vocab = fc_bm.create_vocabulary(32768)
data = fc_bm.create_string_data(
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)
# Keras implementation
model = keras.Sequential()
model.add(
Reported by Pylint.
Line: 39
Column: 1
max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)
# Keras implementation
model = keras.Sequential()
model.add(
keras.Input(
shape=(max_length,), name="data", ragged=True, dtype=tf.string))
model.add(string_lookup.StringLookup(vocabulary=vocab, mask_token=None))
Reported by Pylint.
Line: 40
Column: 1
# Keras implementation
model = keras.Sequential()
model.add(
keras.Input(
shape=(max_length,), name="data", ragged=True, dtype=tf.string))
model.add(string_lookup.StringLookup(vocabulary=vocab, mask_token=None))
# FC implementation
Reported by Pylint.
keras/layers/preprocessing/benchmarks/embedding_dense_benchmark.py
30 issues
Line: 17
Column: 1
# ==============================================================================
"""Benchmark for KPL implementation of embedding column with dense inputs."""
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
Reported by Pylint.
Line: 19
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 20
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 21
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
NUM_REPEATS = 10
Reported by Pylint.
Line: 32
Column: 1
### KPL AND FC IMPLEMENTATION BENCHMARKS ###
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
embedding_size = 32768
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
Reported by Pylint.
Line: 34
Column: 1
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
embedding_size = 32768
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
# Keras implementation
model = keras.Sequential()
Reported by Pylint.
Line: 35
Column: 1
"""Benchmark a variable-length embedding."""
# Data and constants.
embedding_size = 32768
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(None,), name="data", dtype=tf.int64))
Reported by Pylint.
Line: 39
Column: 1
max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(None,), name="data", dtype=tf.int64))
model.add(keras.layers.Embedding(embedding_size, 256))
model.add(keras.layers.Lambda(lambda x: tf.reduce_mean(x, axis=-1)))
# FC implementation
Reported by Pylint.
Line: 40
Column: 1
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(None,), name="data", dtype=tf.int64))
model.add(keras.layers.Embedding(embedding_size, 256))
model.add(keras.layers.Lambda(lambda x: tf.reduce_mean(x, axis=-1)))
# FC implementation
fc = tf.feature_column.embedding_column(
Reported by Pylint.
Line: 41
Column: 1
# Keras implementation
model = keras.Sequential()
model.add(keras.Input(shape=(None,), name="data", dtype=tf.int64))
model.add(keras.layers.Embedding(embedding_size, 256))
model.add(keras.layers.Lambda(lambda x: tf.reduce_mean(x, axis=-1)))
# FC implementation
fc = tf.feature_column.embedding_column(
tf.feature_column.categorical_column_with_identity(
Reported by Pylint.
keras/layers/preprocessing/benchmarks/embedding_varlen_benchmark.py
30 issues
Line: 17
Column: 1
# ==============================================================================
"""Benchmark for KPL implementation of embedding column with varying-length inputs."""
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
Reported by Pylint.
Line: 19
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 20
Column: 1
import tensorflow as tf
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
Reported by Pylint.
Line: 21
Column: 1
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm
# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()
NUM_REPEATS = 10
Reported by Pylint.
Line: 32
Column: 1
### KPL AND FC IMPLEMENTATION BENCHMARKS ###
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
embedding_size = 32768
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
Reported by Pylint.
Line: 34
Column: 1
def embedding_varlen(batch_size, max_length):
"""Benchmark a variable-length embedding."""
# Data and constants.
embedding_size = 32768
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
# Keras implementation
model = keras.Sequential()
Reported by Pylint.
Line: 35
Column: 1
"""Benchmark a variable-length embedding."""
# Data and constants.
embedding_size = 32768
data = fc_bm.create_data(
max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
# Keras implementation
model = keras.Sequential()
model.add(
Reported by Pylint.
Line: 39
Column: 1
max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
# Keras implementation
model = keras.Sequential()
model.add(
keras.Input(shape=(None,), ragged=True, name="data", dtype=tf.int64))
model.add(keras.layers.Embedding(embedding_size, 256))
model.add(keras.layers.Lambda(lambda x: tf.reduce_mean(x, axis=-1)))
Reported by Pylint.
Line: 40
Column: 1
# Keras implementation
model = keras.Sequential()
model.add(
keras.Input(shape=(None,), ragged=True, name="data", dtype=tf.int64))
model.add(keras.layers.Embedding(embedding_size, 256))
model.add(keras.layers.Lambda(lambda x: tf.reduce_mean(x, axis=-1)))
# FC implementation
Reported by Pylint.
Line: 42
Column: 1
model = keras.Sequential()
model.add(
keras.Input(shape=(None,), ragged=True, name="data", dtype=tf.int64))
model.add(keras.layers.Embedding(embedding_size, 256))
model.add(keras.layers.Lambda(lambda x: tf.reduce_mean(x, axis=-1)))
# FC implementation
fc = tf.feature_column.embedding_column(
tf.feature_column.categorical_column_with_identity(
Reported by Pylint.