Difference between Dataset.from_tensors and Dataset.from_tensor_slices
Now we have two methods to do this – Dataset.from_tensors and Dataset.from_tensor_slices.
from_tensors – This method is used to combine several smaller datasets to form a large dataset.
from_tensor_slices – This method is generally used while training machine learning models using data input pipeline. This methods help us to combine the independent features and their target as one dataset.
We will try to understand this one by one using code examples of the same. First of all, the main condition to using the from_tensor_slices is that the dimension of the matrix at the 0th rank must be the same.
Difference Between Dataset.from_tensors and Dataset.from_tensor_slices
In this article, we will learn the difference between from_tensors and from_tensor_slices. Both of these functionalities are used to iterate a dataset or convert a data to TensorFlow data pipeline but how it is done difference lies there. Suppose we have a dataset represented as a Numpy matrix of shape (num_features, num_examples) and we wish to convert it to Tensorflow type tf.data.Dataset.