Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I am getting DatasetV1Adapter return type instead of TensorSliceDataset for tf.data.Dataset.from_tensor_slices(X)

I was just following code samples in the Book "Hands on Machine Learning with scikit-learn and tensorflow".

import tensorflow as tf

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

According to the book I should get type of variable 'dataset' 'TensorSliceDataset shapes:(), types: tf.int32', but instead I am getting 'DatasetV1Adapter shapes: (), types: tf.int32'

like image 768
Shantanu Kumar Avatar asked Jul 10 '19 05:07

Shantanu Kumar


People also ask

What does TF data dataset From_tensor_slices do?

With that knowledge, from_tensors makes a dataset where each input tensor is like a row of your dataset, and from_tensor_slices makes a dataset where each input tensor is column of your data; so in the latter case all tensors must be the same length, and the elements (rows) of the resulting dataset are tuples with one ...

How do I know what shape my TF dataset is?

To get the shape of a tensor, you can easily use the tf. shape() function. This method will help the user to return the shape of the given tensor.

Is TF data dataset a generator?

Dataset objects as generators for the training of a machine learning model on Tensorflow, with parallelized processing. The tf. data pipeline is now the gold standard for building an efficient data pipeline for machine learning applications with TensorFlow.


1 Answers

Based on their documentation, if you're using tf 2.0 (or below) it doesn't support TensorSliceDataset, and will give you DatasetV1Adapter https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/raw_ops

You will need TF 2.1.x and up

like image 186
Yukkee Chang Avatar answered Oct 09 '22 03:10

Yukkee Chang