python - 为什么我得到 DatasetV1Adapter 返回类型而不是 TensorSliceDataset for tf.data.Dataset.from_tensor_slices(X)

标签 python tensorflow machine-learning

我只是在关注“使用 scikit-learn 和 tensorflow 进行机器学习”一书中的代码示例。

import tensorflow as tf

X = tf.range(10)
dataset = tf.data.Dataset.from_tensor_slices(X)

根据这本书,我应该得到变量“数据集”的类型“TensorSliceDataset shapes:(), types: tf.int32”,但我得到的是“DatasetV1Adapter shapes: (), types: tf.int32”

最佳答案

根据他们的文档,如果您使用的是 tf 2.0(或更低版本),它不支持 TensorSliceDataset,并且会给您 DatasetV1Adapter https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/raw_ops

您将需要 TF 2.1.x 及更高版本

关于python - 为什么我得到 DatasetV1Adapter 返回类型而不是 TensorSliceDataset for tf.data.Dataset.from_tensor_slices(X),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56963935/

相关文章:

javascript - tensorflow js RGB从输入img到Lab

python - 我们如何在 TensorFlow 2.0 中使用 lbfgs_minimize

computer-science - 了解神经网络反向传播

python - 使用 matplotlib 的分类变量的直方图

Python:从回调访问对象属性

python - 我应该学习/使用 MapReduce 或其他类型的并行化来完成这项任务吗?

python - 设置 ctypes.Structure 默认值

python - Tensorflow:从先前创建的模型中保存变量子集

machine-learning - Keras model.fit() - 使用哪种训练算法?

machine-learning - 创建自学习情感词典