【发布时间】:2021-04-07 14:08:40
【问题描述】:
使用 CNN 进行图像分类。当model.fit()被调用时,它开始训练模型一段时间,在执行过程中被中断并返回错误信息。
错误信息如下
InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: Input size should match (header_size + row_size * abs_height) but they differ by 2
[[{{node decode_image/DecodeImage}}]]
[[IteratorGetNext]]
[[IteratorGetNext/_4]]
(1) Invalid argument: Input size should match (header_size + row_size * abs_height) but they differ by 2
[[{{node decode_image/DecodeImage}}]]
[[IteratorGetNext]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_8873]
Function call stack:
train_function -> train_function
更新:我的建议是检查数据集的元数据。它帮助解决了我的问题。
【问题讨论】:
-
代码存在一些问题,但我注意到的主要问题是您正在为训练数据集和测试数据集加载相同的目录。
-
@yudhiesh 你的意思是训练集和验证集?是的,它们是使用
image_dataset_from_directory()和不同子集从同一目录加载的。测试集在另一个文件夹中分离。由于它与问题关系不大,所以我没有包括它。 -
很抱歉,这实际上是正确的。我将添加一个包含更改的答案。
-
@yudhiesh 没关系。稍后我会尝试分享访问数据集的链接。
-
你没有具体说明你是如何修复它的?你提到检查元数据,但要寻找什么?你发现了什么?你究竟做了什么来修复它?
标签: python tensorflow keras deep-learning google-colaboratory