简体   繁体   English

Tensorflow 2.x 给我 DatasetV1Adapter 而不是 Dataset

[英]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.重新安装tensorflowtensorflow_datasets包已解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TensorFlow.Data.Dataset 和 DatasetV1Adapter 一样吗? - Is TensorFlow.Data.Dataset the same as DatasetV1Adapter? 为什么我为 tf.data.Dataset.from_tensor_slices(X) 获取 DatasetV1Adapter 返回类型而不是 TensorSliceDataset - Why I am getting DatasetV1Adapter return type instead of TensorSliceDataset for tf.data.Dataset.from_tensor_slices(X) DatasetV1Adapter object 不可订阅 - DatasetV1Adapter object is not subscriptable DatasetV1Adapter 返回意外的数据类型 - DatasetV1Adapter returning unexpected datatype 将 DatasetV1Adapter 形状灰度图像形状扩展到 3 个通道,以利用预训练模型 - Expand DatasetV1Adapter shape grey scale image shape to 3 channels to make use of pretrained models How do I add a dimension to class 'tensorflow.python.data.ops.dataset_ops.DatasetV1Adapter' object in Python? - How do I add a dimension to class 'tensorflow.python.data.ops.dataset_ops.DatasetV1Adapter' object in Python? 使用 MirroredStrategy 时的 AssertionError: isinstance(x, dataset_ops.DatasetV2) - AssertionError when using MirroredStrategy: isinstance(x, dataset_ops.DatasetV2) 如何预处理 Tensorflow 2.x 中实现的 BERT model 的数据集? - How to preprocess a dataset for BERT model implemented in Tensorflow 2.x? Tensorflow 2.X 中 TFLite Model 的测量触发器 - Measuring Flops for TFLite Model in Tensorflow 2.X tensorflow 2.x 可以在最新的 Python 上运行吗? - Can tensorflow 2.x be run on the latest Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM