- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can Tensorflow be used to create a dataset of raw strings from the Illiad dataset using Python?
Tensorflow is a machine learning framework that is provided by Google. It is an open-source framework used in conjunction with Python to implement algorithms, deep learning applications, and much more. It is used in research and for production purposes.
The ‘tensorflow’ package can be installed on Windows using the below line of code −
pip install tensorflow
Tensor is a data structure used in TensorFlow. It helps connect edges in a flow diagram. This flow diagram is known as the ‘Data flow graph’. Tensors are nothing but a multidimensional array or a list.
We will be using the Illiad’s dataset, which contains text data of three translation works from William Cowper, Edward (Earl of Derby), and Samuel Butler. The model is trained to identify the translator when a single line of text is given. The text files used have been preprocessing. This includes removing the document header and footer, line numbers and chapter titles.
We are using Google Colaboratory to run the below code. Google Colab or Colaboratory helps run Python code over the browser and requires zero configuration and free access to GPUs (Graphical Processing Units). Colaboratory has been built on top of Jupyter Notebook.
Example
Following is the code snippet −
print("Creating a test dataset that consists of raw strings") test_ds = all_labeled_data.take(VALIDATION_SIZE).batch(BATCH_SIZE) test_ds = configure_dataset(test_ds) loss, accuracy = export_model.evaluate(test_ds) print("The loss is : ", loss) print("The accuracy is: {:2.2%}".format(accuracy))
Code credit − https://www.tensorflow.org/tutorials/load_data/text
Output
Creating a test dataset that consists of raw strings 79/79 [==============================] - 7s 10ms/step - loss: 0.5230 - accuracy: 0.7909 The loss is : 0.5458346605300903 The accuracy is: 78.16%
Explanation
A test dataset is built where data is grouped into certain batch size.
This data is evaluated using the ‘evaluate’ method.
The loss and accuracy associated with the training data is displayed on the console.
- Related Articles
- How can Tensorflow be used to load the Illiad dataset using Python?
- How can Tensorflow be used to train the Illiad dataset using Python?
- How can Tensorflow be used to download and explore the Illiad dataset using Python?
- How can Tensorflow be used to build vocabulary from tokenized words for Illiad dataset using Python?
- How can Tensorflow be used to convert the tokenized words from Illiad dataset into integers using Python?
- How can Tensorflow be used with Illiad dataset to check how well the test data performs using Python?
- How can Tensorflow be used to split the Illiad dataset into training and test data in Python?
- How can Tensorflow be used to visualize the flower dataset using Python?
- How can Tensorflow be used to explore the dataset and see a sample file from the stackoverflow question dataset using Python?
- How can the Illiad dataset be prepared for training using Python?
- How can Tensorflow be used to configure the stackoverflow question dataset using Python?
- How can Tensorflow be used to prepare the dataset with stackoverflow questions using Python?
- How can Tensorflow be used with Estimators to inspect the titanic dataset using Python?
- How can Tensorflow and Python be used to verify the CIFAR dataset?
- How can Tensorflow be used to standardize the flower dataset?
