python - 类型错误 : object of type 'ImageDataGenerator' has no len()

标签 python machine-learning deep-learning

我的单元格没有显示准​​确性,而是不断收到错误“TypeError:‘ImageDataGenerator’类型的对象没有 len()”

这是我的手机代码:


# evaluate model
_, acc = classifier.evaluate_generator(test_datagen, steps=len(test_datagen), verbose=0)
print('> %.3f' % (acc * 100.0))```

最佳答案

  • len() 函数在 python 中接受列表或字符串作为参数,而 test_datagen 对象是生成器。

  • 要准确了解生成器对象的长度,请尝试此 len(list(test_datagen))

关于python - 类型错误 : object of type 'ImageDataGenerator' has no len(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59962329/

相关文章:

python - Django:如何获取项目中的每个表和该表的所有列?

machine-learning - 在mxnet错误中定义一个简单的神经网络

machine-learning - Caffe 中是否有一个层可以获取 blob 中的任意子 block ?

python - 无法在 Azure Web 应用程序上运行 EXE 文件

python - django无法反转项目级别 View ?

python - 尝试改编 TensorFlow 的 MNIST 示例给出 NAN 预测

powershell - ConvertFrom-String 模板存在不规则数据集问题

tensorflow - 当 mAP 不稳定时,我应该什么时候停止对象检测模型训练?

python - 为什么我不能从我的 Python 代码中 "save as"一个 Excel 文件?

machine-learning - 虚拟机和 Ubuntu 14.04 中 GoogLeNet 模型的不同输出