I am new in use of tensoflow, so at the moment I wish to run sum code using the tokenizer function that calls a .lower() module on some texts, but the result is an attribute error as follows:
.vocabulary.update(tokenizer.tokenize(text.numpy().lower()))
^^^^^^^^^^^^^^^^^^
AttributeError: 'numpy.ndarray' object has no attribute 'lower'
PS C:UsersUSER>
Here is the bulk of my code which I expected to give a no error result
(ds_train, ds_test), ds_info = tfds.load(
"mnist",
split=["train", "test"],
shuffle_files=True,
as_supervised=True,
with_info=True
)
def normalize_img(image, label):
return tf.cast(image, tf.float32)/255.0, label
AUTOTUNE = tf.data.experimental.AUTOTUNE
BATCH_SIZE = 64
ds_train = ds_train.map(normalize_img, num_parallel_calls=AUTOTUNE)
ds_train = ds_train.cache()
ds_train = ds_train.shuffle(ds_info.splits["train"].num_examples)
ds_train = ds_train.batch(BATCH_SIZE)
ds_train = ds_train.prefetch(AUTOTUNE)
ds_test = ds_test.map(normalize_img, num_parallel_calls=AUTOTUNE)
de_test = ds_test.batch(128)
ds_test = ds_test.prefetch(AUTOTUNE)
model = keras.Sequential ([
keras.Input(28, 28, 1),
layers.Conv2D(32, 3, activation='relu', padding="same"),
layers.Flatten(),
layers.Dense(10),
])