- 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 has optimization techniques that help in performing complicated mathematical operations quickly. This is because it uses NumPy and multi−dimensional arrays. These multi−dimensional arrays are also known as ‘tensors’. The framework supports working with deep neural network.

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 multidimensional array or a list.

Keras is a deep learning API, which is written in Python. It is a high-level API that has a productive interface that helps solve machine learning problems. It runs on top of Tensorflow framework. It was built to help experiment in a quick manner. Keras is already present within the Tensorflow package. It can be accessed using the below line of code.

import tensorflow from tensorflow import keras

We are using the 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("Defining a sequential model") def create_model(): model = tf.keras.models.Sequential([ keras.layers.Dense(512, activation='relu', input_shape=(784,)), keras.layers.Dropout(0.2), keras.layers.Dense(10) ]) model.compile(optimizer='adam', loss=tf.losses.SparseCategoricalCrossentropy(from_logits=True), metrics=[tf.metrics.SparseCategoricalAccuracy()]) return model print("Creating a model instance") model = create_model() print("Displaying the architecture of the sequential model") model.summary()

Code credit − https://www.tensorflow.org/tutorials/keras/save_and_load

A sequential model is created using Keras.

The layers are created which are ‘dense’.

This model is compiled.

An instance of this model is created.

Details about this model are displayed on the screen using the ‘summary’ method.

- Related Questions & Answers
- How can TensorFlow be used to build the model for Fashion MNIST dataset in Python?
- How can TensorFlow be used to train the model for Fashion MNIST dataset in Python?
- How can Tensorflow be used to save and load weights for MNIST dataset?
- How can TensorFlow be used to make predictions for Fashion MNIST dataset in Python?
- How can Tensorflow be used with Estimators to train the model for titanic dataset?
- How can Tensorflow be used with abalone dataset to build a sequential model?
- How can TensorFlow be used to download and explore the Fashion MNIST dataset using Python?
- How can Tensorflow and pre-trained model be used to configure the dataset for performance?
- How can Tensorflow be used with Fashion MNIST dataset so that the trained model is used to predict a different image in Python?
- How can MNIST data be used with TensorFlow for recognizing handwritten digits?
- How can Tensorflow be used with flower dataset to continue training the model?
- How can Tensorflow be used to configure the dataset for performance?
- How can Tensorflow and Estimator be used to define input function for training and evaluation of dataset?
- How can Tensorflow be used to configure the flower dataset for performance?
- How can TensorFlow be used to verify the predictions for Fashion MNIST in Python?

Advertisements