如何保存 tf.data.Dataset 对象? [英] How to save tf.data.Dataset object?

查看:55
本文介绍了如何保存 tf.data.Dataset 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如上.我尝试对其进行酸洗,但出现此错误:

As above. I tried pickling it, but I got this error:

maybe_arr = self._cpu_nograd()._numpy() # pylint:disable=protected-access

maybe_arr = self._cpu_nograd()._numpy() # pylint: disable=protected-access

运行时错误:Tensorflow 类型 21 无法转换为 numpy dtype.

RuntimeError: Tensorflow type 21 not convertible to numpy dtype.

推荐答案

tf.data.Dataset 是一个更抽象的对象,其工作是定义数据管道.如果你想保存中间结果以加速你的数据管道,你可以使用 tf.data.Dataset.cache()tf.data.Dataset.prefetch() (更多关于这里)

tf.data.Dataset is a more abstract object whose job is to define the data pipeline. If you want to save intermediate results to speed up your data pipeline you can use tf.data.Dataset.cache() or tf.data.Dataset.prefetch() (more on it here)

如果您对保存数据管道中的操作序列感兴趣,我假设没有这样的事情,您需要保留数据管道的代码.我不知道有什么方法可以提取 Dataset API 的数据管道图.如果有人知道这一点,请添加到答案中.

If you are interested in saving the sequence of operations in your data pipeline, I assume there is no such thing and you need to keep the code for data pipeline. I am not aware of any method that can extract the graph of data pipeline of Dataset API. If anyone is aware of that please add to the answer.

这篇关于如何保存 tf.data.Dataset 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆