"ValueError: Asked to retrieve element 0, but the Sequence has length 0" in Convolutional Neural Network

"ValueError: Asked to retrieve element 0, but the Sequence has length 0" in Convolutional Neural Network

我正在使用此代码:https://github.com/gsurma/image_classifier/blob/master/ImageClassifierCNN.ipynb but I get this error: ValueError: Asked to retrieve element 0, but the Sequence has length 0 on this line: probabilities = model.predict_generator(test_generator, TEST_SIZE) . I followed this suggestion: How can I get rid of getting error through test generator? and I changed the above line to this: probabilities = model.predict(test_generator, TEST_SIZE) but does not work! And this: ValueError: Asked to retrieve element 0, but the Sequence has length 0 没有适合我的情况的解决方案。知道哪里出了问题吗?

经过搜索我发现我需要在“test”文件夹中包含2个文件夹,文件夹名称是“cat”和“dog”。为了查看所有测试图像,我将 TEST_SIZE = ... 更改为“测试”文件夹下 2 个文件夹内的图像总数。