Skip to content

Commit 81f06d1

Browse files
Fixes "'float' object cannot be interpreted as an integer" in Python 3.12
PiperOrigin-RevId: 720231366
1 parent ad06941 commit 81f06d1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tf_keras/preprocessing/sequence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def skipgrams(
365365
random.shuffle(words)
366366

367367
couples += [
368-
[words[i % len(words)], random.randint(1, vocabulary_size - 1)]
368+
[words[i % len(words)], random.randint(1, int(vocabulary_size - 1))]
369369
for i in range(num_negative_samples)
370370
]
371371
if categorical:
@@ -375,7 +375,7 @@ def skipgrams(
375375

376376
if shuffle:
377377
if seed is None:
378-
seed = random.randint(0, 10e6)
378+
seed = random.randint(0, int(10e6))
379379
random.seed(seed)
380380
random.shuffle(couples)
381381
random.seed(seed)

tf_keras/utils/text_dataset_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _prepare_directory(
3333
):
3434
# Get a unique temp directory
3535
temp_dir = os.path.join(
36-
self.get_temp_dir(), str(random.randint(0, 1e6))
36+
self.get_temp_dir(), str(random.randint(0, int(1e6)))
3737
)
3838
os.mkdir(temp_dir)
3939
self.addCleanup(shutil.rmtree, temp_dir)

0 commit comments

Comments
 (0)