【发布时间】:2022-11-26 09:36:53
【问题描述】:
这是我的代码:
train_images = tf.keras.utils.image_dataset_from_directory(
'/content/drive/MyDrive/ArabicHandwritten2/train')
train_labels = tf.keras.utils.image_dataset_from_directory(
'/content/drive/MyDrive/ArabicHandwritten2/test')
train_images = tf.reshape(train_images.shape[0], 256, 256, 3).astype('float32')
train_images = (train_images - 127.5) / 127.5 # Normalize the images to [-1, 1]
BUFFER_SIZE = 16765
BATCH_SIZE = 32
train_dataset = tf.data.Dataset.from_tensor_slices(train_images).shuffle(BUFFER_SIZE).batch(BATCH_SIZE)
错误是:
AttributeError: 'BatchDataset' object has no attribute 'shape'
我该如何解决错误?
谢谢。
【问题讨论】:
-
我们能看到整个回溯吗?
标签: python tensorflow shapes reshape