在Tensorflow数据集中显示示例不起作用 [英] Show examples in tensorflow datasets not working
本文介绍了在Tensorflow数据集中显示示例不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想加载tensorflow flowers 数据集并使用 tfds.show_examples .
I want to load the tensorflow flowers dataset and visualize it using tfds.show_examples.
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import tensorflow_hub as hub
import tensorflow_datasets as tfds
from tensorflow.keras import layers
import logging
logger = tf.get_logger()
logger.setLevel(logging.ERROR)
(train_examples, validation_examples), info = tfds.load(
'tf_flowers',
with_info=True,
as_supervised=True,
split=['train[:70%]', 'train[70%:]'],
)
fig = tfds.show_examples(train_examples, info)
运行代码时,我没有看到图像,而是收到一条错误消息:
When I run my code, instead of seeing images, I get an error message:
AttributeError Traceback (most recent call last)
<ipython-input-13-dcdedbcd800d> in <module>()
6 )
7
----> 8 fig = tfds.show_examples(train_examples, info)
/usr/local/lib/python3.6/dist-packages/tensorflow_datasets/core/visualization.py in show_examples(ds_info, ds, rows, cols, plot_scale, image_key)
68 # Infer the image and label keys
69 image_keys = [
---> 70 k for k, feature in ds_info.features.items()
71 if isinstance(feature, features_lib.Image)
72 ]
AttributeError: 'DatasetV1Adapter' object has no attribute 'features'
为什么这不起作用?
推荐答案
我在使用Colab时遇到了同样的问题.试试这个
I had the same problem using Colab. Try this
pip install --upgrade tensorflow-datasets
然后重新启动内核
这篇关于在Tensorflow数据集中显示示例不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文