Skip to content

Commit

Permalink
Try a fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdangerw committed Sep 19, 2024
1 parent 56f2ba7 commit 843cfe4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions keras_nlp/src/utils/tensor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import keras
import numpy as np
from keras import ops
from collections.abc import Mapping
from collections.abc import Sequence

try:
import tensorflow as tf
Expand Down Expand Up @@ -115,13 +117,13 @@ def convert_preprocessing_inputs(x):
if not tf.executing_eagerly() or in_no_convert_scope():
return x

if isinstance(x, dict):
if isinstance(x, Mapping):
return {k: convert_preprocessing_inputs(x[k]) for k, v in x.items()}
if isinstance(x, tuple):
return tuple(convert_preprocessing_inputs(v) for v in x)
if isinstance(x, (str, bytes)):
return tf.constant(x)
if isinstance(x, list):
if isinstance(x, Sequence):
try:
numpy_x = np.array(x)
except ValueError as e:
Expand Down

0 comments on commit 843cfe4

Please sign in to comment.