我目前正在使用
训练存储为numpy数组的数据集train_dataset=tf.data.Dataset.from_tensor_slices(train_data)
在这里,train_data是一个不包含相关标签的numpy数据数组。创建我正在运行的模型以将其作为DatasetV1Adapters(MNIST和pix至pix GAN的数据集)用于数据集。我一直在寻找可以进行必要的更正的文档,时间已经有一段时间了(大约4周)。而且这种方法没有解决我的问题。
在训练过程中,我正在跑步:
for images in train_dataset:
#images=np.expand_dims(images, axis=0)
disc_loss += train_discriminator(images)
哪个会给我一个错误
ValueError: Input 0 of layer conv2d_2 is incompatible with the layer: expected ndim=4, found ndim=3.
数组的形状为[32,32,3],因此丢失了100个图像。我试图运行注释掉的行images = np.expand_dims(images,axis = 0)。因此,我得到了[1,32,32,3],它与我所需的尺寸相匹配。我以为我的问题可以解决,但是现在我出现了以下错误:
ValueError: Input 0 of layer conv2d_4 is incompatible with the layer: expected axis -1 of input shape to have value 1 but received input with shape [1, 32, 32, 3]
我不太了解。好像错误肯定与datasetV1Adapter有关,因为我得到的同一类错误是各种代码。我尝试将数据集上传到github,但是作为10GB文件夹,我无法实际上传它。任何帮助将不胜感激
编辑:遵循@ Sebastian-Sz的建议(关闭)。我将模型中的通道设置为三个,以容纳RGB而不是灰度。运行这段代码给了我
TypeError: Value passed to parameter 'input' has DataType uint8 not in list of allowed values: float16, bfloat16, float32, float64
所以我添加了
train_data = np.asarray(train_data, dtype=np.float)
现在我收到一条错误消息:
Input 0 of layer dense_5 is incompatible with the layer: expected axis -1 of input shape to have value 6272 but received input with shape [1, 8192]
这对我没有意义