- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

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.

They can be identified using three main attributes −

**Rank**− It tells about the dimensionality of the tensor. It can be understood as the order of the tensor or the number of dimensions in the tensor that has been defined.**Type**− It tells about the data type associated with the elements of the Tensor. It can be a one dimensional, two dimensional or n-dimensional tensor.**Shape**− It is the number of rows and columns together.

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.

Following is the code snippet −

print("The exported model is being compiled") export_model.compile( loss=losses.SparseCategoricalCrossentropy(from_logits=False), optimizer='adam', metrics=['accuracy'])

Code credit − https://www.tensorflow.org/tutorials/load_data/text

The exported model is being compiled

Once the model has been exported, it is compiled using the ‘compile’ method.

- Related Questions & Answers
- How can Tensorflow be used to compile the model using Python?
- How can Tensorflow be used to compile and fit the model using Python?
- How can Tensorflow be used with Estimator to compile the model using Python?
- How can Tensorflow and pre-trained model be used to compile the model using Python?
- How can Tensorflow be used to train and compile the augmented model?
- How can Tensorflow be used to train and compile a CNN model?
- How can Tensorflow be used to train the model using Python?
- How can Tensorflow used with the pre-trained model to compile the model?
- How can Tensorflow be used to export the model built using Python?
- How can Tensorflow be used to export the built model using Python?
- How can Tensorflow be used with the flower dataset to compile and fit the model?
- How can Tensorflow be used with Estimators to evaluate the model using Python?
- How can Tensorflow be used to fit the data to the model using Python?
- How can Tensorflow be used to compare the linear model and the Convolutional model using Python?
- How can Tensorflow be used to evaluate a CNN model using Python?

Advertisements