【发布时间】:2021-07-17 16:02:12
【问题描述】:
大家好,我是 tensorflow 的新手,我在胶囊网络上工作 这就是我的数据集的样子:
-train
|-class1
|-class2
|-class3
我正在使用 ImageDataGenerator flow_from_directory 从目录名称生成标签:
train = ImageDataGenerator(rescale= 1/255)
trainData = train.flow_from_directory(dir_path , class_mode='categorical' , target_size=(80, 80), batch_size=batch_size )
这是标签的占位符:
y = tf.placeholder(shape=[None], dtype=tf.int64, name="y")
我正在关注的教程是在 mnist 数据集上工作,所以他这样做是为了将训练数据提供给模型:
X_batch, y_batch = mnist.train.next_batch(batch_size)
我这样做了:
X_batch, y_batch = trainData.next()
它适用于图像,但不适用于 labell,因为我收到了这个错误:
Cannot feed value of shape (10, 3) for Tensor 'y:0', which has shape '(?,)'
y_batch.shape --> (10, 3) 10 是 batch_size,我猜 3 是类数,我对此感到困惑
有人可以帮忙吗?
【问题讨论】:
标签: python tensorflow deep-learning