ONLINE SUMMER TRAINING Online Courses Free Tutorials 
 Placement Preparation 
Artificial Intelligence(AI) & Machine Learning(ML) Training in Jaipur
0 like 0 dislike
424 views
in Artificial Intelligence(AI) & Machine Learning by Goeduhub's Expert (3.1k points)
tf.data.Dataset.from_tensor_slices()

Goeduhub's Online Courses @Udemy

For Indian Students- INR 570/- || For International Students- $12.99/-

S.No.

Course Name

Apply Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence

Apply Coupon

2.

Computer Vision with OpenCV | Deep Learning CNN Projects

Apply Coupon

3.

Complete Machine Learning & Data Science with Python Apply Coupon

4.

Natural Language Processing-NLP with Deep Learning in Python Apply Coupon

5.

Computer Vision OpenCV Python | YOLO| Deep Learning in Colab Apply Coupon

6.

Complete Python Programming from scratch with Projects Apply Coupon

1 Answer

0 like 0 dislike
by Goeduhub's Expert (3.1k points)
 
Best answer

tf.data.Dataset.from_tensor_slices: tf.data.Dataset.from_tensor_slices() return slices of an array in object form. 

Basically when we convert a complex input pipeline into a simple input pipeline, we use tf.data API in tensorflow.

For example for text data we do preprocessing of data : removing symbols, embedding  and batching different length sequences together etc...

So, basically with help of tf.data  we can handle these complex processes and  large amount of data.

To convert a complex input pipeline into simple input pipeline, first we need data. For example 

We use tf.data.Dataset.from_tensors() or tf.data.Dataset.from_tensor_slices() to construct a Dataset from data in the memory.

Now let's see an example.

#import tensorflow 

import tensorflow as tf  

# use of  tf.data.Dataset.from_tensor_slices method

dataset = tf.data.Dataset.from_tensor_slices([1, 2, 3, 4, 5, 6])

for elem in dataset:

  print(elem.numpy())

Output

# import tensorflow 

import tensorflow as tf  

# use of  tf.data.Dataset.from_tensor_slices method

dataset = tf.data.Dataset.from_tensor_slices([[8, 3] , [9, 2]])

print(next(iter(dataset)))

Output

tf.Tensor([8 3], shape=(2,), dtype=int32)

Note: Actually creating a simple pipeline in machine learning is always challenging then model building. we can use tf.data for data in tensorflow.

Our Mentors(For AI-ML)


Sharda Godara Chaudhary

Mrs. Sharda Godara Chaudhary

An alumna of MNIT-Jaipur and ACCENTURE, Pune

NISHA (IIT BHU)

Ms. Nisha

An alumna of IIT-BHU

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...