keras TypeError:不支持/的操作数类型:"批处理数据集"和"浮点型"

8fsztsew  于 2023-02-04  发布在  其他
关注(0)|答案(1)|浏览(195)

我试图将'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.
zujrkrfu

zujrkrfu1#

这是因为您试图用不可除类型Dataset除float。
tf.data.Dataset

相关问题