我有一个目录,其中仅包含我想用作数据集的名为 train_set 的jpeg图像。该目录与我的python脚本位于同一目录。我尝试按照www.tensorflow.org上的教程进行操作,以便将所有图像加载到 train_set 中。我最终使用了以下代码:
data_dir = "train_set/*.jpg"
list_ds = tf.data.Dataset.list_files(data_dir)
for f in list_ds.take(5):
print(f.numpy())
调用print会产生以下错误:
AttributeError: 'Tensor' object has no attribute 'numpy'
list_ds 似乎为空。我去了documentation page of the list_files method并尝试使用全路径,相对路径,并且还将Pathlib强制转换为字符串作为参数,但是并没有真正改变。我不确定自己在做什么错。