Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/bert_pretraining/bert_create_pretraining_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def write_instance_to_example_files(
writer = tf.io.TFRecordWriter(output_filename)
total_written = 0
lookup = dict(zip(vocab, range(len(vocab))))
for (inst_index, instance) in enumerate(instances):
for inst_index, instance in enumerate(instances):
token_ids = [lookup[x] for x in instance.tokens]
padding_mask = [1] * len(token_ids)
segment_ids = list(instance.segment_ids)
Expand Down Expand Up @@ -379,7 +379,7 @@ def create_masked_lm_predictions(
# (Issue #166)

cand_indexes = []
for (i, token) in enumerate(tokens):
for i, token in enumerate(tokens):
if token == "[CLS]" or token == "[SEP]":
continue
cand_indexes.append([i])
Expand Down
6 changes: 5 additions & 1 deletion keras_nlp/layers/masked_lm_mask_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ def call(self, inputs):
# convert dense to ragged.
inputs = tf.RaggedTensor.from_tensor(inputs)

(token_ids, mask_positions, mask_ids,) = tf_text.mask_language_model(
(
token_ids,
mask_positions,
mask_ids,
) = tf_text.mask_language_model(
inputs,
item_selector=self._random_selector,
mask_values_chooser=self._mask_values_chooser,
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/metrics/bleu.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _corpus_bleu(
smooth: boolean. Whether or not to apply Lin et al. 2004
smoothing.
"""
for (references, translation) in zip(
for references, translation in zip(
reference_corpus, translation_corpus
):
reference_length += min(len(r) for r in references)
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/models/albert/albert_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def __init__(
num_segments=2,
**kwargs,
):

if num_layers % num_groups != 0:
raise ValueError(
"`num_layers` must be divisible by `num_groups`. Received: "
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/models/bart/bart_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def __init__(
max_sequence_length=1024,
**kwargs,
):

# Encoder inputs
encoder_token_id_input = keras.Input(
shape=(None,), dtype="int32", name="encoder_token_ids"
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/models/bert/bert_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def __init__(
num_segments=2,
**kwargs,
):

# Index of classification token in the vocabulary
cls_token_index = 0
# Inputs
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/models/deberta_v3/deberta_v3_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def __init__(
bucket_size=256,
**kwargs,
):

# Inputs
token_id_input = keras.Input(
shape=(None,), dtype="int32", name="token_ids"
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/models/distil_bert/distil_bert_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def __init__(
max_sequence_length=512,
**kwargs,
):

# Inputs
token_id_input = keras.Input(
shape=(None,), dtype="int32", name="token_ids"
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/models/f_net/f_net_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def __init__(
num_segments=4,
**kwargs,
):

# Index of classification token in the vocabulary
cls_token_index = 0
# Inputs
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/models/gpt2/gpt2_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def __init__(
max_sequence_length=1024,
**kwargs,
):

# Inputs
token_ids = keras.Input(shape=(None,), dtype="int32", name="token_ids")
padding_mask = keras.Input(
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/models/gpt2/gpt2_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def __init__(
sequence_length,
**kwargs,
):

super().__init__(**kwargs)

self.tokenizer = tokenizer
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/models/roberta/roberta_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def __init__(
max_sequence_length=512,
**kwargs,
):

# Inputs
token_id_input = keras.Input(
shape=(None,), dtype=tf.int32, name="token_ids"
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/samplers/beam_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def sample(
)

def one_step(beams, beams_prob, length, mask):

flattened_beams = tf.reshape(
beams, shape=[batch_size * num_beams, -1]
)
Expand Down
1 change: 0 additions & 1 deletion keras_nlp/tokenizers/byte_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ def vocabulary_size(self) -> int:
return 256

def tokenize(self, inputs):

if not isinstance(inputs, (tf.Tensor, tf.RaggedTensor)):
inputs = tf.convert_to_tensor(inputs)

Expand Down
1 change: 0 additions & 1 deletion keras_nlp/tokenizers/byte_tokenizer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def test_load_model_with_config(self):
)

def test_config(self):

tokenizer = ByteTokenizer(
name="byte_tokenizer_config_test",
lowercase=False,
Expand Down