python - InvalidArgumentError : Expected 'tf.Tensor(False, shape=(), dtype=bool)' to be true. 汇总数据:b'没有文件匹配模式:

标签 python tensorflow deep-learning tensorflow2.0 tensorflow-datasets

当我在 Google colab 上运行以下代码时,

tf.data.Dataset.list_files('/content/gdrive/MyDrive/Experiment/train/*.jpg')

我收到以下错误:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-4-8d9cebdfe01f> in <module>()
----> 1 tf.data.Dataset.list_files('/content/gdrive/MyDrive/Experiment/train/*.jpg')

3 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/control_flow_ops.py in Assert(condition, data, summarize, name)
    162           op=None,
    163           message="Expected '%s' to be true. Summarized data: %s" %
--> 164           (condition, "\n".join(data_str)))
    165     return
    166 

InvalidArgumentError: Expected 'tf.Tensor(False, shape=(), dtype=bool)' to be true. Summarized data: b'No files matched pattern: /content/gdrive/MyDrive/Experiment/train/*.jpg'

最近两周我一直被这个问题困扰着,请帮帮我。此外,在运行上述代码行之前,我已经成功安装了 Google 驱动器。

最佳答案

您的文件名中可能有一些无效字符,例如:.,* 删除这些字符为我解决了问题。

关于python - InvalidArgumentError : Expected 'tf.Tensor(False, shape=(), dtype=bool)' to be true. 汇总数据:b'没有文件匹配模式:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67800765/

相关文章:

machine-learning - 如何初始化词汇表外的词嵌入?

python - 仅增强 K 折交叉验证中的训练集

python - 如何将 @tf.function 与 Keras 顺序 API 一起使用?

tensorflow - 如何在 Google Colab 中降级 Cuda 和 cuDNN 版本?

python - 如何在自定义 tf.keras.layers.Layer 中支持 mask

python - 为什么在 Keras 子类化 API 中,永远不会调用 call 方法,而是通过调用此类的对象来传递输入?

python - 如何将ndarray转换为数组?

python - python的通用捕获

python - Python 是否有类的默认构造函数?

python - 从 Tensorflow DeepLab v3 演示中提取图像分割图