简体   繁体   English

如何从 tf.dataset 打印样本记录?

[英]How to print sample records from tf.dataset?

I have a tensorflow dataset called imdb.我有一个名为 imdb 的 tensorflow 数据集。 How can I print top 5 records of this dataset (including header)?如何打印此数据集的前 5 条记录(包括标题)? I am looking for something similar to dataframe.head() in pandas.我在 pandas 中寻找类似于dataframe.head()的东西。 Some of the datasets can have images as well.一些数据集也可以有图像。

   import tensorflow_datasets as tfds
   imdb, info = tfds.load("imdb_reviews", with_info=True, as_supervised=True)

The code print(type(imdb)) returns <class 'dict'> .代码print(type(imdb))返回<class 'dict'> I understand tfds.show_examples supports only images.我了解tfds.show_examples仅支持图像。 Thank you.谢谢你。

Assuming you have eager execution enabled, this will show the first five examples:假设您启用了急切执行,这将显示前五个示例:

for x in imdb['train'].take(5):
    print(x)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM