我试图将'train'除以255以进行正常化,但我得到以下错误:
"类型错误:不支持/的操作数类型:"批处理数据集"和"浮点型""
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
path=r'C:\Users\faisa\Desktop\sample_cropped' #Change this to work with your directory
batch_size = 1
img_height = 28
img_width = 28
train = tf.keras.utils.image_dataset_from_directory(path,
validation_split = 0.15,
subset = "training",
seed = 123,
color_mode="grayscale",
image_size = (img_height, img_width),
batch_size = batch_size)
X = train/255.
1条答案
按热度按时间zujrkrfu1#
这是因为您试图用不可除类型Dataset除float。
tf.data.Dataset