[英]Tensorflow 2.x giving me DatasetV1Adapter instead of Dataset
I am trying to load the 'voc' dataset from the tensorflow datasets.我正在尝试从 tensorflow 数据集加载“voc”数据集。 When I was able to successfully load the dataset using the below code:当我能够使用以下代码成功加载数据集时:
ds = tfds.load('voc', split=['train','test'], shuffle_files=True)
I also printed out the ds, I got that:我还打印了 ds,我得到了:
[<DatasetV1Adapter shapes: {image: (None, None, 3), image/filename: (), labels: (None,), labels_no_difficult: (None,), objects: {bbox: (None, 4), is_difficult: (None,), is_truncated: (None,), label: (None,), pose: (None,)}}, types: {image: tf.uint8, image/filename: tf.string, labels: tf.int64, labels_no_difficult: tf.int64, objects: {bbox: tf.float32, is_difficult: tf.bool, is_truncated: tf.bool, label: tf.int64, pose: tf.int64}}>, <DatasetV1Adapter shapes: {image: (None, None, 3), image/filename: (), labels: (None,), labels_no_difficult: (None,), objects: {bbox: (None, 4), is_difficult: (None,), is_truncated: (None,), label: (None,), pose: (None,)}}, types: {image: tf.uint8, image/filename: tf.string, labels: tf.int64, labels_no_difficult: tf.int64, objects: {bbox: tf.float32, is_difficult: tf.bool, is_truncated: tf.bool, label: tf.int64, pose: tf.int64}}>] [<DatasetV1Adapter 形状:{图像:(无,无,3),图像/文件名:(),标签:(无,),labels_no_difficult:(无,),对象:{bbox:(无,4),is_difficult: (无,),is_truncated:(无,),label:(无,),姿势:(无,)}},类型:{图像:tf.uint8,图像/文件名:tf.string,标签:tf.int64 , labels_no_difficult: tf.int64, objects: {bbox: tf.float32, is_difficult: tf.bool, is_truncated: tf.bool, label: tf.int64, pose: tf.int64}}>, <DatasetV1Adapter 形状: {image: (无,无,3),图像/文件名:(),标签:(无,),labels_no_difficult:(无,),对象:{bbox:(无,4),is_difficult:(无,),is_truncated:(无,),label:(无,),姿势:(无,)}},类型:{图像:tf.uint8,图像/文件名:tf.string,标签:tf.int64,labels_no_difficult:tf.int64,对象:{bbox:tf.float32,is_difficult:tf.bool,is_truncated:tf.bool,label:tf.int64,姿势:tf.int64}}>]
and tried to be sure that the loaded is an instance of tf.data.Dataset, I got an assertion error.并试图确保加载的是 tf.data.Dataset 的一个实例,但我得到了一个断言错误。
assert isinstance(ds, tf.data.Dataset)
Instead, it says that it is an instance of DatasetV1Adapter.相反,它说它是 DatasetV1Adapter 的一个实例。 I am using tensorflow version 2.2.0 (I have printed out to see if I was mistaken, print(tf. version ) printed out 2.2.0).我正在使用 tensorflow 版本 2.2.0(我打印出来看看我是否弄错了,打印(tf. version )打印出 2.2.0)。 I am also using 2.1.0 version of tensorflow.datasets library.我也在使用 2.1.0 版本的 tensorflow.datasets 库。 Should not be the type of ds Dataset instead of DatasetV1Adapter since I'm using tf 2.x?因为我使用的是 tf 2.x,所以不应该是 ds Dataset 而不是 DatasetV1Adapter 的类型?
edit: After working on this specific problem for nearly 10 hours, I was able to solve it.编辑:在解决这个特定问题近 10 个小时后,我能够解决它。 The solution was fairly simple and straightforward, I reinstalled the packages tensorflow and tensorflow_datasets.解决方案相当简单明了,我重新安装了包 tensorflow 和 tensorflow_datasets。
@Furkan Akkurt, thank you for your solution. @Furkan Akkurt,感谢您的解决方案。 For the benefit of community i am providing solution here (answer section)为了社区的利益,我在这里提供解决方案(答案部分)
Reinstall the tensorflow
and tensorflow_datasets
packages has resolved the issue.重新安装tensorflow
和tensorflow_datasets
包已解决该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.