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'
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 ...
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With